В отвечая на недавнюю визуализацию мне действительно нужны скобки, чтобы показать пролет на оси, и я не могу понять, как это сделать в ggplot2. Здесь сюжет:
Вместо метки, мне бы очень хотелось, чтобы метка оси y "Вторая буква двухбуквенных имен" имела брекет, простирающийся от 1 до 10 (вертикальный интервал красных и синих вторых букв). Но я не уверен, как это сделать. Ось х могла бы выиграть от подобного лечения.
Код доступен в связанном CrossValidated вопросе (и излишне сложный для этого примера, поэтому я его не покажу). Вместо этого здесь минимальный пример:
library(ggplot2)
x <- c(runif(10),runif(10)+2)
y <- c(runif(10),runif(10)+2)
qplot(x=x,y=y) +
scale_x_continuous("",breaks=c(.5,2.5),labels=c("Low types","High types") )
В этом случае скобка из (0,1) для низких типов и из (2,3) для высоких типов была бы идеальной, а не галочкой.
Я бы предпочел не использовать geom_rect
, потому что:
- Маркировка останется
- Я бы предпочел скобки
- Он будет внутри сюжета, а не вне его
Как бы я это сделал? Идеальный ответ:
- Хорошая, гладкая, тонкая фигурная скобка
- Выполняется за пределами области печати
- Определяется с помощью аргумента высокого уровня (в идеале объект типа диапазона, переданный в опцию
breaks
вscale_x_continuous
)