(1)scale_shape_continuous() 这个函数真的存在吗?? (2)scale_shape_binned() 将连续变量分箱(bin)后映射为离散的形状。 library(ggplot2) # 将连续变量 cty 分箱并映射为形状 ggplot(mpg, aes(x = displ, y = hwy, shape = cty)) + geom_point(size = 3) + sc
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, size = Petal.Width, shape = Specie...
p=ggplot(mtcars%>%mutate(am=as.factor(am)))+geom_point(aes(mpg,disp,colour=am))## 更改 x 间隔为5p+scale_x_continuous(name="X name(distance = 10)",breaks=breaks_width(10))->p1 ## 更改 x 间隔为2p+scale_x_continuous(name="X name(distance = 2)",breaks=breaks_width(2))->p2 ...
方法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...
tip.length=0.01)+scale_size_continuous(range=c(1,3))+scale_fill_manual(values=c("#3CB2EC","#9C8D58"))+labs(x=NULL,y=NULL)+theme_test()+theme(plot.margin=unit(c(0,0.5,0.5,0.5),units=,"cm"),axis.line=element_line(color="black",size=0.3),panel.grid.minor=element_blank(),...
基于连续变量的点的大小的图例, 使用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)) +ylim(c(...
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)) ...
scale_y_discrete 1. 连续型变量坐标轴 函数及其参数: scale_x_continuous(name=,#坐标轴标签breaks=,#定义刻度minor_breaks=,labels=,#刻度标签limits=,expand=c(0.05,0),#坐标轴延伸,确保图形元素不覆盖坐标oob=censor,#识别越过边界的点na.value=NA_real_,trans='identity',#统计变换position='bottom',#le...
# 代码来自 http://sape.inf.usi.ch/quick-reference/ggplot2/shaped=data.frame(p=c(0:25,32:127))ggplot() +scale_y_continuous(name="") +scale_x_continuous(name="") +scale_shape_identity() +geom_point(data=d, mapping=aes(x=p%%16, y=p%/%16, shape=p), size=5, fill="red") ...
> scalexx <- scalex[grepl("scale_size.+", scalex)] > unique(gsub("(([^_]+_){2})(.+)","\\3",scalexx)) [1] "area" "binned" "binned_area" "continuous" "date" "datetime" "discrete" "identity" [9] "manual" "ordinal" ...