0

I need to create a break in the y-axis, so I can show very low values, skip 90% of the y-axis and then show the very high values. How would I do this in r with ggplot?

Code is not needed, this is more of a conceptual question. I want something like below.

enter image description here

Spacedman
  • 92,590
  • 12
  • 140
  • 224
SantiClaus
  • 666
  • 2
  • 8
  • 22
  • 2
    You can't by design, as cut axes produce misleading graphs. `scale_y_log10` or facetting may be good alternatives. – alistaire Jul 15 '18 at 00:42
  • Maybe you can take something from [this](https://stackoverflow.com/questions/39733972/ggplot2-custom-grob-over-axis-lines/40622343#40622343) – Sandy Muspratt Jul 15 '18 at 19:40

1 Answers1

1

The functions scale_x_discrete() and scale_y_discrete() are used to customize discrete x and y axis, respectively. Just define your own breaks.

scale_x_discrete(name, breaks, labels, limits)
scale_y_discrete(name, breaks, labels, limits)
  1. name : x or y axis labels
  2. breaks : control the breaks in the guide (axis ticks, grid lines, …). Among the possible values, there are : NULL : hide all breaks waiver() : the default break computation a character or numeric vector specifying which breaks to display

  3. labels : labels of axis tick marks. Allowed values are : NULL for no labels waiver() for the default labels character vector to be used for break labels

  4. limits : a character vector indicating the data range

Reference this link

ReKx
  • 996
  • 2
  • 10
  • 23