plot of chunk unnamed-chunk-11 如果想要修改颜色、方向、粗细等,就要使用theme()函数修改。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 p1<-p+theme(axis.text.x=element_text(color="red",size=14,angle=45,hjust=1,vjust=1),axis.text.y=element_text(color="blue","size=15",angle=90))...
# Setupoptions(scipen=999)library(ggplot2)data("midwest",package="ggplot2")theme_set(theme_bw())# Add plot components ---gg<-ggplot(midwest,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+geom_smooth(method="loess",se=F)+xlim(c(0,0.1))+ylim(c(0,500000))+la...
p+ggtitle("Age and Height\nof Schoolchildren")+theme(plot.title = element_text(size = rel(1.5),lineheight = .9,family = "Times",face = "bold.italic",colour = "red")) # rel(1.5)表示字体大小将为当前主题基准字体大小的1.5倍 # 对于主题元素来说,字体大小(size)的单位为磅(pt) # 要设置...
theme(plot.title=element_text(face="bold.italic",color="steelblue",size=24, hjust=0.5,vjust=0.5,angle=360,lineheight=113)) 下面为theme的相关参数,可以细节修改处,之后的后面会继续补充。 function (base_size = 12, base_family = "") { theme(line = element_line(colour = "black", size = ...
ggplot(data=Arthritis, mapping=aes(x=Improved,fill=Sex))+geom_bar(stat="count",width=0.5,position='stack')+scale_fill_manual(values=c('#999999','#E69F00'))+geom_text(stat='count',aes(label=..count..), color="white", size=3.5,position=position_stack(0.5))+theme_minimal() ...
ggplot(data=Salaries, aes(x=yrs.since.phd, y=salary, color=rank)) +scale_color_brewer(palette="Set1") + geom_point(size=2) 把palette="Set1"用其他的值(例如"Set2"、"Set3"、"Pastel1"、"Pastel2"、"Paired"、"Dark2"或"Accent")来...
geom_line(color = "firebrick", linetype = "dotted", size = .3) 替换默认的ggplot2主题 为了进一步说明ggplot的多用途性,让我们通过设置一个不同的内置主题(例如theme_bw())来摆脱灰色的默认ggplot2外观——通过调用theme_set()。 theme_set(theme_bw()) ...
set.seed(1234) df <- mtcars[sample(1:nrow(mtcars), 10), ] df$cyl <- as.factor(df$cyl) 散点图注释 # Scatter plot sp <- ggplot(df, aes(x=wt, y=mpg))+ geom_point() # Add text, change colors by groups sp + geom_text(aes(label = rownames(df), color = cyl), size = ...
qplot()类似于R基本绘图函数plot(),可以快速绘制常见的几种图形:散点图、箱线图、 小提琴图、直方图以及密度曲线图。其绘图格式为: qplot(x, y=NULL, data, geom="auto") 1. 其中: x,y: 根据需要绘制的图形使用; data:数据集; geom:几何图形,变量x,y同时指定的话默认为散点图,只指定x的话默认为直方...
ggplot(data=Arthritis, mapping=aes(x=Improved,fill=Sex))+geom_bar(stat="count",width=0.5,position='stack')+scale_fill_manual(values=c('#999999','#E69F00'))+geom_text(stat='count',aes(label=..count..), color="white", size=3.5,position=position_stack(0.5))+theme_minimal() ...