,ggplot2-plotly|让你的火山图“活”过来,ggplot2|扩展包从0开始绘制雷达图,ggplot2| 绘制KEGG气泡图,ggplot2|绘制GO富集柱形图,ggplot2|从0开始绘制PCA图,ggplot2|ggpubr进行“paper”组图合并,本文将介绍一些对legend的细节操作来完成图形的“精雕细琢”。 载入R包和数据 mtcars
p <- ggplot(mtcars, aes(x=gear, y=mpg, fill=gear)) + geom_boxplot() p 设置legend position 使用theme() 参数设置legend位置 # 可选参数为“left”,“top”, “right”, “bottom”. p + theme(legend.position="bottom") # 数值向量 c(x,y...
设置legend position 使用theme() 参数设置legend位置 # 可选参数为“left”,“top”, “right”, “bottom”.p+theme(legend.position="bottom") # 数值向量c(x,y) 调控位置p+theme(legend.position = c(0.8,0.2)) 更改legend 的title , font styles # legend titlep+theme(legend.title=element_text(co...
theme(plot.title = element_text(lineheight=.8, size=10, face="bold",hjust = 0.5)) + theme(legend.title=element_text(face="bold",size=8)) + theme(legend.text=element_text(face="italic",size=9))+ xlab("x") + ylab("y") + theme(axis.title.x =element_text(face="italic",size...
#gear为横坐标,对mpg做箱线图,gear填充颜色 p <- ggplot(mtcars, aes(x=gear, y=mpg, fill=gear)) + geom_boxplot() p 设置legend position 使用theme() 参数设置legend位置 # 可选参数为“left”,“top”, “right”, “bottom”. p + theme(legend.position="bottom") # 数值向量 c(x,y) 调...
legend.text = element_text(size = 11), plot.title = element_text(hjust = 0.5), text = element_text(family = "serif")) # 拼图 p1+p2 9.单独设置分面子图坐标轴 可用这个包进行子图坐标单独设置:ggh4x包 library(ggh4x) data <- data.frame(class = c('z'), x = 1:10, value = 1, ...
(ggplot(mtcars,aes(‘wt’,‘mpg’,color=’factor(cyl)’))+geom_point()+labs(title=’Miles per gallon vs Weight’,x=’Weight’,y=’Miles per gallon’)+guides(color=guide_legend(title=’NumberofCylinders’))) R中的ggplot的主要卖点之一是FACET的能力。对于用一行代码绘制数据子集,我们也有许多...
? 1 bp + theme(legend.position="top") 也可以根据坐标来设置图例的位置, 左下角为 (0,0), 右上角为(1,1) ? 1 2 # Position legend in graph, where x,y is 0,0 (bottom left) to 1,1 (top right) bp + theme(legend.position=c(.5, .5)) ? 1 2 3 4 # Set the "anchoring ...
最终绘制出了想要的曼哈顿图,效果看起来还不错,有需要的可以借鉴学习,小果今天的分享就到这里。 往期代码: 【1】lncRNA的拷贝数变异下游相关分析【2】R可视化:ggstatsplot包—科研界的美图秀秀【3】随机森林算法用于分类预测和筛选诊断标志物【4】基于本地Java版GSEA的输出结果整合多个通路到一张图【5】基于岭回归...
In this case, we are creating a legend at the bottom of the plots. However, you may modify this legend to your specific needs.# Create plot with legend ggp1_legend <- ggplot(data1, aes(x = x, y = y, group = group, col = group)) + geom_point() + theme(legend.position = "...