- R Graphs Cookbook Second Edition
- Jaynal Abedin Hrishi V. Mittal
- 178字
- 2021-08-05 17:30:34
Highlighting grouped data points by size and symbol type
Sometimes, we might not want to use different colors to represent different groups of data points. For example, some journals accept graphs only in grayscale. In this recipe, we will learn how we can highlight grouped data points by symbol size and type.
Getting ready
We will use the ggplot2
library, so let's load it by running the following command:
library(ggplot2)
How to do it...
First, let's group points by the symbol type. Once again, we use the qplot()
function:
qplot(disp,mpg,data=mtcars,shape=as.factor(cyl))

Next, let's group the points simply by the size of the plotting symbol:
qplot(disp,mpg,data=mtcars,size=as.factor(cyl))

How it works...
Highlighting groups of points by symbol type and size works exactly like colors using the qplot()
functions. Instead of the col
argument, we used the shape
and size
arguments and set them to the factor we want to group the points by (in this case, cyl
). We can also use combinations of any of these arguments. For example, we can use colors to represent cyl
and size to represent the gear.
- FPGA從入門到精通(實戰篇)
- Android NDK Game Development Cookbook
- 數字道路技術架構與建設指南
- 精選單片機設計與制作30例(第2版)
- Manage Partitions with GParted How-to
- 電腦維護365問
- Mastering Adobe Photoshop Elements
- Machine Learning with Go Quick Start Guide
- 微型計算機系統原理及應用:國產龍芯處理器的軟件和硬件集成(基礎篇)
- Intel Edison智能硬件開發指南:基于Yocto Project
- Mastering Machine Learning on AWS
- Angular 6 by Example
- 嵌入式系統設計大學教程(第2版)
- UML精粹:標準對象建模語言簡明指南(第3版)
- 3D打印:Geomagic Design X5.1 逆向建模設計實用教程