I have a bar chart which was based on code provided here:
library(tidyverse)
dat <- data.frame(x = rep(3 - 0.4, 301),
xend = rep(3 + 0.4, 301),
y = seq(from = 0, to = 3, by = 0.01),
yend = seq(from = 0, to = 3, by = 0.01))
dat %>%
ggplot(aes(x = x, xend = xend, y = y, yend = yend, color = y)) +
geom_segment(size = 2) +
scale_color_gradient2(low = "green", mid = "yellow", high = "red",
midpoint = max(dat$y)/2) +
coord_flip() +
theme(legend.position = "blank",
axis.title = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank())
Can anybody help me modify this chart so that the x-axis scale (which is really a y-axis scale but which has been flipped), goes from -100% to 100%, ideally with breaks at 25% intervals, with the percentages shown in absolute values? My desired end result is the following:
Even if the underlying data is not modified that is fine - I just need to modify the axis labels. I'll eventually plot an hline on top of it, which is based on a -1 to 1 scale, but I can do the math to get the right placement on the 0 to 3 scale,