- 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.
- Aftershot Pro:Non-destructive photo editing and management
- 電腦組裝與維修從入門到精通(第2版)
- 深入淺出SSD:固態存儲核心技術、原理與實戰
- 硬件產品經理手冊:手把手構建智能硬件產品
- 深入淺出SSD:固態存儲核心技術、原理與實戰(第2版)
- Source SDK Game Development Essentials
- BeagleBone Robotic Projects
- 基于PROTEUS的電路設計、仿真與制板
- Istio服務網格技術解析與實踐
- Hands-On Motion Graphics with Adobe After Effects CC
- 筆記本電腦維修技能實訓
- 微服務實戰
- The Applied Artificial Intelligence Workshop
- Service Mesh微服務架構設計
- Learning Microsoft Cognitive Services