Data visualization¶
This page covers data visualization using different programming languages.
Related pages: Data description • Diagramming
Resources¶
Documentation¶
Cheatsheets¶
Style guides¶
Templates¶
Style¶
theme_minimal() +
theme(
panel.grid.major.y = element_line(color = "gray90", linewidth = 0.3),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
axis.title.x = element_text(margin = margin(t = 8)),
axis.title.y = element_text(margin = margin(r = 8)),
axis.title = element_text(size = 10, color = "black"),
axis.text = element_text(size = 9, color = "black"),
axis.line = element_line(color = "black", linewidth = 0.3),
axis.ticks.x = element_line(color = "black", linewidth = 0.3),
axis.ticks.y = element_line(color = "black", linewidth = 0.3),
legend.position = "top",
legend.title = element_blank(),
legend.text = element_text(size = 9, color = "black"),
legend.key.height = unit(10, "pt"),
legend.key.width = unit(10, "pt"),
legend.margin = margin(b = 0) # or -10
)
Graphs made from one dataset¶
Languages and packages¶
ggplot2¶
R
ggplot(data = DATA) +
GEOM_FUNCTION() +
COORDINATE_FUNCTION() +
FACET_FUNCTION() +
SCALE_FUNCTION() +
ANNOTATION_FUNCTION() +
THEME_FUNCTION()
Summary¶
§1. Types of graphs¶
Bar plots¶
Line plots¶
TBD
TBD
TBD
Plots with intervals¶
Graphs with intervals are great for visualizing confidence intervals, among other things.
A rule of thumb: error cap \(\approx\) \(20--25\%\) of bar width.
TBD
TBD
Stakced area plots¶
Scatter plots¶
TBD
TBD
TBD
Binned scatter plots¶
TBD
TBD
TBD
Coefficient plots¶
TBD
TBD
TBD
§2. Scales¶
Percentages¶
Log scale¶
TBD
§3. Plot elements¶
Vertical/horizontal lines¶
Grid¶
Axis title¶
Legend¶
§4. Data Aesthetics¶
Color (color / fill)¶
In the terminology of ggplot2, color refers to both the color and fill aesthetics.
Transparency¶
TBD
Linetype¶
TBD
Linewidth¶
TBD
Shape¶
TBD
Size¶
TBD
§5. Manipulating plots¶
Faceting¶
Combining plots¶
Exporting plots¶
For reproducibility, we can specify as many ambiguously determined parameters as possible.
Figure size recommendations:
Full page width:
- 6.5 \(\times\) 3.5 in
Middle ground:
-
6 \(\times\) 3.5 in
-
6 \(\times\) 3.8 in
Compact:
- 4.8 \(\times\) 3.2 in