1

assume the following MWE:

library(ggplot2)
library(ggthemes)

set.seed(100)
df <- data.frame(x = rnorm(50), y = rnorm(50))

ggplot(df, aes(x,y)) +
  geom_point() +
  theme_tufte() +
  geom_rangeframe() +
  scale_x_continuous(breaks = extended_range_breaks()(df$x),
                     labels = scales::number_format(accuracy = 0.1))+
  scale_y_continuous(breaks = extended_range_breaks()(df$y),
                     labels = scales::number_format(accuracy = 0.1))

enter image description here

From my point of view the number of ticks on the y-axis is not enough, the space between 1.0 and 2.9 is too large and I would like to have another tick at 2.0. Anyone an idea how to do that when working with extended_range_breaks or do I have to switch to manually setting the ticks?

I tried scale_y_continuous(n.breaks = 7) and scale_y_continuous(breaks = extended_range_breaks(n = 7)(df$y) but both don't have an effect.

Felix Phl
  • 383
  • 1
  • 13
  • How about setting `breaks = scales::breaks_width(0.4)` or another fitting number? I don't understand the choice for the ggthemes version. – teunbrand Jul 24 '20 at 11:24
  • @teunbrand the advantage of the ggthemes version is the automatical inclusion of the min and max values – Felix Phl Jul 24 '20 at 12:42

1 Answers1

0

Not a perfect answer, but at least a work-around for now: change the weights applied to the four optimization components. The parameters are set to w = c(0.25, 0.2, 0.5, 0.05) for simplicity, coverage, density, and legibility. If we set coverage for example to 2 (for the y-axis), the graph changes to the following:

enter image description here

The actual desired goal to simly add (-2,2) was yet not possible with this tweak.

Felix Phl
  • 383
  • 1
  • 13