简体   繁体   English

如何更改散点图的字体和填充颜色?

[英]How do I change the font of, and color the fill of the scatterplot?

I would like to change the font and fill the background of the variables in my scatterplot.我想更改字体并填充散点图中变量的背景。 I've had no success.我没有成功。

crime <- read.csv('http://datasets.flowingdata.com/crimeRatesByState2005.csv',sep=",", header=TRUE)

crime2 <- crime[crime$state != "District of Columbia",]
crime2 <- crime2[crime2$state != "United States",]

windowsFonts(D=windowsFont("Georgia"))

pairs(crime2[,2:9]
      , panel=panel.smooth
      , col.smooth = "blue"
      , col="gray"
      , pch=16 #dot fill
      , labels=c("Murder","Forcible Rape","Robbery","Aggrevated \n Assault","Burglary","Larceny/Theft","Motor Vehicle \n Theft","Population")
      , font.labels=1 #normal
      , font.main=3 #italics
      , cex.labels=1.5 #size
      , las=1 #horizontal
      #, font.family="D"
      #, labels.family="D"
      #, cex.family="D"
      ) 
mtext("Rates per 100,000 population \n  \n ", side=3, adj=0, line=1.2, cex=1, font=3, family="D")

Try something to the effect of plot(1:10, pch=21, col="black", bg="lightblue") .尝试一些效果plot(1:10, pch=21, col="black", bg="lightblue") You have to use a pch value that can have a background color (21 through 25, see ?points ), and you specify the outer color with col and the inner color with bg (see ?par and/or ?points ).您必须使用可以具有背景颜色(21 到 25,请参阅?points )的pch值,并使用col指定外部颜色,使用bg指定内部颜色(请参阅?par和/或?points )。

As for the font, you might be referring to the family argument of par() .至于字体,您可能指的是par()family参数。 These can be graphical device specific (and different OS's use different default graphical devices; eg, par(family="Times") gives Time New Roman on a Mac, but not PC), but some fonts like "serif", "sans", and "mono" work cross platform.这些可以是特定于图形设备的(并且不同的操作系统使用不同的默认图形设备;例如, par(family="Times")在 Mac 上提供 Time New Roman,但在 PC 上不提供),但某些字体如“serif”、“sans” ,和“单声道”跨平台工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改 corrplot 的颜色、字体类型和大小? - How do I change the color, font type and size of a corrplot? 如何更改 R 中 corrplot 中特定变量的字体颜色? - How do I change the font color of specific variables in corrplot in R? 如何更改 Flexdashboard valueBox() 的字体颜色 - How do I change font color for Flexdashboard valueBox() 如何使用R中的绘图功能更改散点图中x轴和y轴标签的字体大小和颜色? - How to change the font size and color of x-axis and y-axis label in a scatterplot with plot function in R? R,scatterplot3d:为分组分配特定颜色并更改字体 - R, scatterplot3d: Assigning specific color to group and change font 如何使用字符在散点图的 y 尺度上更改标签? - How do I change labels on y scale of a scatterplot using characters? 如何在ggplot2中更改散点图的颜色 - How to change color of scatterplot in ggplot2 如何在geom_bar中更改计算变量的填充颜色 - How do I change the fill color for a computed variable in geom_bar 如何在ggplot2的scale_fill_brewer中更改一个值的颜色值? - How do I change the color value of just one value in ggplot2's scale_fill_brewer? 在R中,如何让散点图根据另一个变量的值为点选择颜色? - in R, how do I have the scatterplot choose a color for a point based on the value of another variable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM