[Beginner] Graph for Communication - Label
Evan Jung 1/3/2019
1. Introduction
In EDA(Exploratory Data Analysis), many ways to build plots as tools for exploration. Most of you made each plot for some reason and purpose for clients. To let clients understand your data and graph, you need to know the way to communicate your thoughts and understandings to others.
We will review R for Data Science written by Garrett Grolemund & Hadley Wichham.
This simple article aims to R users who knows how to draw graph using tidyverse package. If you are newbie for R, then click above the link and read chapter 3 carefully.
We are on chater 28, though.
2. Label
The easiest place to start when turning an explorator graphic into an expository graphic is with good labels. You add labes with labs
(1) labs() function
What is titie? Well, in general, title is big picture of graph, summarizing the main finding. Part of facts, e.g. “A scatterplot of displ and hwy” is not the title because it has no any finding from Analyst.
(2) Subtitle & Caption
If you want to add more text, giving more information to clients, then you may think of subtitle & caption.
Look!
- Subtitle adds additional detail in a smaller font beneath the title
- caption adds text at the bottom right of the plot, often used to describe the source of the data
(3) x and y title replacement
Look graph 1 & 2. The titles of x and y are a bit strange to read it. Yes, clients can’t understand those abbreviation, so you want to spread it to full name. On the other hand, when you code with R, you want to select variable typing letters. Then, you might be introuble to code.
labs function makes both of group easy to do the job.
ggplot(mpg, aes(displ, hwy)) + geom_point(aes(colour = class)) + geom_smooth(se = FALSE) + labs( x = "Engine displacement (L)", y = "Highway fuel economy (mpg)", colour = "Car type" )
(4) Formula on X and Y
This is option. If you working with math, physics, etc. You want to put formula to x-axis and y-axis. Below the way.
df <- tibble( x = runif(10), y = runif(10) ) ggplot(df, aes(x, y)) + geom_point() + labs( x = quote(sum(x[i] ^ 2, i == 1, n)), y = quote(alpha + beta + frac(delta, theta)) )
It looks difficult. but You can do it with R Documentation. Type on code chunk ?plotmath like below
Let me introduce some quotes
Syntax | Meaning |
---|---|
x + y | x plus y |
x - y | x minus y |
sqrt(x) | square root of x |
'R > [R] Data Visualization' 카테고리의 다른 글
[R Markdown] Customized Report (DataCamp) (0) | 2019.05.04 |
---|---|
[R] Interactive Data Visualisation using leaflet (2) (0) | 2019.03.03 |
[R] Interactive Data Visualisation using leaflet (1) (0) | 2019.03.02 |
How to draw graph for two numeric variables in R (0) | 2019.01.17 |