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

时间:2015-06-30 16:23:54

标签: r scatter-plot

我想更改字体并填充散点图中变量的背景。我没有成功。

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")

1 个答案:

答案 0 :(得分:0)

尝试plot(1:10, pch=21, col="black", bg="lightblue")的效果。您必须使用可以具有背景颜色的pch值(21到25,请参阅?points),并使用col指定外部颜色,使用{{1指定内部颜色(见bg和/或?par)。

至于字体,您可能指的是?points的{​​{1}}参数。这些可以是特定于图形设备的(并且不同的操作系统使用不同的默认图形设备;例如,family在Mac上提供Time New Roman,但不提供PC),但有些字体如&#34; serif&# 34;,&#34; sans&#34;和&#34; mono&#34;跨平台工作。