Take a sad chart and make it better

with ggplot2 and other tools

Rules don't always apply.

Never use 3D.

Never use 3D.

@tylermorganwall

Use < 7 colors.

Use < 7 colors.

and more...

@trang1618

I'm Trang Le.

I have made some (very) bad charts.

https://trang.page

What's your favorite R package for visualization?

Let's learn a bit about you!

identify key idea

select chart type

I would use histograms or stacked bar charts for each comparison. Caveat: node sizes not shown.

DOL3 vs. DOL0

DOL7 vs. DOL0

Metabolome

Proteome

Transcriptome

Novel nodes

reduce cognitive burden

aesthetically pleasing = good?

direct labeling

reduce the number of labels

highlighting

facets FTW

facet_grid(
  cols = vars(...),
  scales = 'free', 
  space = 'free')
labs(x = NULL, color = NULL)

NULL, NA and element_blank()

theme(axis.title.x = element_blank(),
      legend.title = element_blank())
theme_set(
  theme_bw() + 
  theme(legend.title = element_blank())
)
scale_y_continuous(
  breaks = seq(0, 1, 0.2),
  labels = scales::percent_format(accuracy = 0.1),
  expand = expansions(mult = c(0, .1)))
# Setting the limits with the scale discards 
# all data outside the range.
lims(x = c(20, NA), y = c(NA, 40))


# As of June 2019, this is allowed (and recommended)
coord_cartesian(xlim = c(20, NA), ylim = c(NA, 40))
# Setting the limits with the scale discards 
# all data outside the range.
lims(x = c(20, NA), y = c(NA, 40))


# As of June 2019, this is allowed (and recommended)
coord_cartesian(xlim = c(20, NA), ylim = c(NA, 40))
+ coord_fixed(ratio = 1)

Histograms heavily depend on bin width and location

but sometimes binning is helpful... 

e.g. to solve overcrowding problem

ggcyto::ggcyto() + geom_hex(bins = 64)
ggplot(data = my_world) +
    geom_sf(aes(fill = fct_relevel(region, region_levels))) +
    coord_sf(crs = "+proj=eqearth +wktext")

- consistent color legends

- clear labeling

- use of SHAP

 

paper ≠ presentation

US-affiliated scientists

US-affiliated scientists

US-affiliated scientists

US-affiliated scientists

US-affiliated scientists

know when to stop

library(treeheatr)
heat_tree(penguins, target_lab = 'species')

Very quick on
colors and themes

  • color: sequential, quantitative, divergent
    • colorblind friendly palettes
  • themes

Resources

(Alberto Cairo)

Nadieh Bremer,

Will Chase's winning data story

tidytuesday submission

 

windRose(openair_data)

Great data stories