美文网首页
1123 chapter 21 ggplot2进行图形化沟通

1123 chapter 21 ggplot2进行图形化沟通

作者: 森尼啊 | 来源:发表于2018-11-24 11:37 被阅读0次

标签

labs()
title,subtitle,caption,quote

注释

geom_text(), geom_hline(),geom_vline(),geom_rect(),
geom_segment()

标度

  • 一般有默认标度
  • breaks替换默认标度 scale_y_continuous(breaks = seq(15,40,by = 5))
    y轴从15开始到40,间隔为5;
    scale_y_continuous(labels = NULL) ,不显示刻度
  • 控制图例的整体位置theme(),控制与数据无关的部分,ledgend.position = none,不显示图例
ggplot(mpg, aes(displ,hwy))+
    geom_point()+
    theme(ledgend.position = "right") # 默认位置
  • 标度替换
    scale_x_log10()
    scale_color_brewer()

缩放

控制图形的三种方法

  • 调整绘图数据
  • 设置标度范围
  • 在 coord_cartesian()函数中设置xlim和ylim的参数
    coord_cartesian(xlim = c(5,7),ylim = c(10,30))

主题

ggplot2默认8种主题
theme_bw(),theme_light()等

保存图形

ggsave(),knitr()
控制图形大小的几个参数,
fig.width, fig.height, fig.asp, out.width, out.height
常用的默认值
fig.width = 6,
fig.asp = 0.618,
out.width = “70%”,
fig.align = "center"
fig.show = "hold",图形显示在代码后面

相关文章

网友评论

      本文标题:1123 chapter 21 ggplot2进行图形化沟通

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