Primary exercises

  1. Logarithmic scale and manual colors.
    For the pulse data construct the plot shown below.
    Add scale_x_log10 and scale_y_log10 to change both location scales to logarithmic.
    Enforce the same limits from 50 to 150 on both scales.
ggplot( pulse ) +
  aes( x = pulse1, y = pulse2, color = ran ) +
  geom_point() +
  scale_x_log10( limits = c( 50, 150 ) ) + 
  scale_y_log10( limits = c( 50, 150 ) ) +
  xlab( "pulse1 (before exercise) [1/min]" ) +
  ylab( "pulse2 (after exercise) [1/min]" ) +
  scale_color_manual( values = c( ran = "black", sat = "orange" ) )

Extra exercises

  1. Advanced scales.
    The scales package extends ggplot2 functionality by providing “tools to override the default breaks, labels, transformations and palettes”.
    Have a look at the package reference manual to get familiar with types of scales it may provide for your projects.


Copyright © 2023 Biomedical Data Sciences (BDS) | LUMC