ggplot2标度图层(scale layer)可简单理解为图形中辅助您读图的一些组件,如不同颜色、形状、线性、大小、图例、坐标轴名称等等,详细介绍为。
Scales in ggplot2 control the mapping from data to aesthetics. They take your data and turn it into something that you can see, like size, colour, position or shape. They also provide the tools that let you interpret the plot: the axes and legends. You can generate plots with ggplot2 without knowing how scales work, but understanding scales and learning how to manipulate them will give you much more control.
In ggplot2, guides are produced automatically based on the layers in your plot. You don’t directly control the legends and axes; instead you set up the data so that there’s a clear mapping between data and aesthetics, and a guide is generated for you. This is very different to base R graphics, where you have total control over the legend, and can be frustrating when you first start using ggplot2. However, once you get the hang of it, you’ll find that it saves you time, and there is little you cannot do.Divide scales into three main groups:
- Position scales and axes.(位置标度和坐标轴)
- Colour scales and legends.(颜色标度和图例)
- Other scales for non-position aesthetics.(其它非位置图像属性标度)
本文详细介绍位置标度和坐标轴 (Position scales and axes),续前篇