美文网首页
R语言学习笔记ggplot2

R语言学习笔记ggplot2

作者: 思亮笔记 | 来源:发表于2020-03-18 10:35 被阅读0次

1.从一个简单的boxplot开始

rm(list = ls())    #清空所有环境变量
if(!require(ggplot2))install.packages('ggplot2')  #条件安装ggplot2
library(ggplot2)      #加载ggplot2
ggplot(iris,aes(x =  Species,y = Sepal.Length, fill = Species))+
  geom_boxplot()    #利用内置数据集iris
001.png

2.利用theme_set()修改

theme_set(theme_classic())
ggplot(iris,aes(x =  Species,y = Sepal.Length, fill = Species))+
  geom_boxplot()
002.png

3.利用labs()修改

ggplot(iris,aes(x =  Species,y = Sepal.Length, fill = Species))+
  geom_boxplot()+
  labs(title = 'title from labs',subtitle = 'subtitle from labs',x ='',y='',caption = 'caption from labs')
003.png

4.利用theme()修改

ggplot(iris,aes(x =  Species,y = Sepal.Length, fill = Species))+
  geom_boxplot()+
  labs(title = 'title from labs',subtitle = 'subtitle from labs',x =NULL,y=NULL,caption = 'caption from labs')+
  theme(legend.position = 'None')
004.png
ggplot(iris,aes(x =  Species,y = Sepal.Length, fill = Species))+
  geom_boxplot()+
  labs(title = 'title from labs',subtitle = 'subtitle from labs',x ='',y='',caption = 'caption from labs')+
  theme(axis.text.x = element_text(angle=65, vjust=0.6))
005.png

备注

+ coord_polar() #转换为极坐标
+ coord_flip()  #交换X轴和Y轴
dev.off()  #关闭画板设备

相关文章

  • 学习小组Day4笔记--行

    正式开始学习R语言了,今天笔记内容为R语言基础和ggplot2的入门学习 R语言基础 1、认识R与RStudio ...

  • 学习小组Day4 -- ksprings

    学习资料 R for Data Science R数据科学--详解ggplot2 学习笔记 准备--载入包 tid...

  • 生信学习小组80期 Day4-CM

    今天分享的笔记如何使用r语言中ggplot2包进行绘图。 安装ggplot2包 使用install.package...

  • ggplot2绘图学习

    学习书籍:ggplot2:数据分析与图形艺术 R语言常用函数(参考来源) 通过上周R语言基础的学习,这周复习上周知...

  • 《R语言实战》中ggplot2之Salaries数据集调用

    学会用R语言中的ggplot2这个包做图非常重要,这两天学习《R语言实战》第19章ggplot2 做图,当把第40...

  • R语言之ggplot2画图篇

    R语言之ggplot2画图篇

  • R语言学习笔记ggplot2

    1.从一个简单的boxplot开始 2.利用theme_set()修改 3.利用labs()修改 4.利用them...

  • ggplot2 作图

    作者:严涛浙江大学作物遗传育种在读研究生(生物信息学方向)伪码农,R语言爱好者,爱开源 ggplot2学习笔记之图...

  • 2020-05-14

    学习小组DAY4笔记-lyq 今天初探R语言 R语言安装 R语言面板在简单了解

  • R语言 -- ggplot2 学习

    菜鸡又来学画图了,菜鸡总共整理了大概一天半 这些当然只是冰山一角,以后遇到其他问题会继续补充,奥利GAY! 原始图...

网友评论

      本文标题:R语言学习笔记ggplot2

      本文链接:https://www.haomeiwen.com/subject/ihdmdhtx.html