ggplot2: 坐标轴修饰

https://liuxingming.blog.csdn.net/article/details/47427453?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-6.control&dist_request_id=1619594496511_22734&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-6.control
https://blog.csdn.net/zx403413599/article/details/48581713
https://blog.csdn.net/weixin_42568714/article/details/113073762


删除整个坐标轴(保留坐标轴标题):

theme(axis.line = element_blank(),axis.text = element_blank(),axis.ticks = element_blank())


1. 删除刻度标签

plot() + theme(axis.text = element_blank())

2. 删除刻度线

plot() + theme(axis.ticks = element_blank())

3. 修改刻度显示范围和刻度间隔

scale_x_continuous(limits=c(起始值,终止值), breaks=seq(起始值, 终止值, 间隔))
scale_y_continuous(limits=c(起始值,终止值), breaks=seq(起始值, 终止值, 间隔))

4. 删除坐标轴线

plot() + theme(axis.line = element_blank())

ggplot(mtcars)+geom_bar(aes(x=cyl))+theme_cowplot()  '#正常绘制坐标轴线,示例一
ggplot(mtcars)+geom_bar(aes(x=cyl))+theme_cowplot()+theme(axis.line = element_line(size=1, colour = "black"))  #修改坐标轴线的粗细和颜色,示例二
ggplot(mtcars)+geom_bar(aes(x=cyl))+theme_cowplot()+theme(axis.line = element_line(size=0, colour = "black"))  #通过修改坐标轴线的颜色删除坐标轴线,示例二
ggplot(mtcars)+geom_bar(aes(x=cyl))+theme_cowplot()+theme(axis.line = element_line(size=1, colour = "white"))  #通过修改坐标轴线的粗度删除坐标轴线,示例二
ggplot(mtcars)+geom_bar(aes(x=cyl))+theme_cowplot()+theme(axis.line = element_blank()))  #直接删除坐标轴线,示例二
示例一

示例二
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容