[英]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.