scale_color_gradient(low = "#f0cf61", high = "#371722") + scale_size_continuous(range = c(1, 4)) + theme_classic() + labs(x = "Sepal Length", y = "Sepal Width", title = "Iris Sepal") + theme(plot.title = element_text(size = 15, face = "bold", hjust = 0.5), axis....
scale_size_continuous(range = c(1, 4)) + theme_classic() + labs(x = "Sepal Length", y = "Sepal Width", title = "Iris Sepal") + theme(plot.title =element_text(size = 15, face = "bold", hjust = 0.5), axis.title = element_text(face = "bold"), legend.title = element_tex...
p+scale_x_reverse(breaks=as.numeric(X),labels=Labels,position="top")+scale_y_continuous(breaks=seq(2,5,0.5),limits=c(2,5),position="right")+theme(axis.ticks.length=unit(-0.2,"cm")) 总结一下以上图形完整代码: ggplot(data=iris,aes(x=Sepal.Length,y=Sepal.Width,color=Petal.Length,siz...
方法2,scale_xxx_discrete/continuous() library(ggplot2) data=data.frame(x=1:10,y=1:5,z=factor(1:5)) ggplot(data,aes(x=x,y=y,shape=z,color=z,size=x))+geom_point()+ scale_x_continuous(name='横轴2')+scale_y_continuous(name='纵轴2')+ scale_color_discrete(name='颜色2')+scale...
scale_size_continuous(range = c(1,10)) 1. 2. 3. 4. image.png 气泡图将透明度设置低一点可能会好看一点 ggplot(df,aes(x=ID,y=log2FC, color=Class,size=pvalue))+ geom_point(alpha=0.5)+ scale_size_continuous(range = c(1,10)) ...
14ggplot(data, aes(x=carat, y=price, size=depth)) + 15geom_point(alpha=0.2) 即使是气泡图,各个数据间的大小比较并不是很明显,所以需要时使用scale_size_continuous()函数。 1ggplot(data, aes(x=carat, y=price, size=depth)) + 2geom_point(alpha=0.2) + ...
p <- ggplot(cdat, aes(x=healthexp, y=infmortality, size=GDP)) + geom_point(shape=21, colour="black", fill="cornsilk") #将GDP映射给半径(scale_size_continuous的默认值) p #将GDP映射给面积,得到略大的圆圈 p + scale_size_area(max_size=15)...
基于连续变量的点的大小的图例, 使用 scale_size_continuous() 函数 1 2 3 4 5 6 7 8 9 10 library(ggplot2) # Base Plot 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)) ...
scale函数:图形遥控器。坐标轴标度函数: scale_x_continous scale_y_continous scale_x_discrete scale_y_discrete 1. 连续型变量坐标轴 函数及其参数: scale_x_continuous(name=,#坐标轴标签breaks=,#定义刻度minor_breaks=,labels=,#刻度标签limits=,expand=c(0.05,0),#坐标轴延伸,确保图形元素不覆盖坐标oob=...
geom_point(aes(colour=class,size=displ),alpha=0.6,position = "jitter")+ stat_smooth()+ scale_size_continuous(range = c(4, 10))+ facet_wrap(~ year,ncol=1)+ ggtitle("汽车油耗与型号")+ labs(y='每加仑高速公路行驶距离', x='每加仑城市公路行驶距离')+ ...