[英]How to make a dotplot with a discontinuous axis in R
Hi I'm trying to make a dotplot but have got pretty big differences between my groups so am trying to create a graph with breaks in the axis to display this:嗨,我正在尝试制作一个点图,但我的组之间有很大的差异,所以我试图创建一个在轴上带有中断的图表来显示这个:
Condition![]() |
Value![]() |
---|---|
A![]() |
0 ![]() |
A![]() |
0 ![]() |
A![]() |
0 ![]() |
B![]() |
650 ![]() |
B![]() |
1600 ![]() |
B![]() |
900 ![]() |
C ![]() |
85000 ![]() |
C ![]() |
15000 ![]() |
C ![]() |
60000 ![]() |
The script I've used is:我使用的脚本是:
p<-ggplot(d, aes(x=Condition, y=Value, fill=Condition))+ geom_dotplot(binaxis = 'y', stackdir = "center", position=position_dodge(), dotsize = .6)+ ylim(0,90000) p2<-p+scale_y_break(c(10,600), scales=50)+scale_y_break(c(2000,12000),scales = 150)
This puts the breaks where I want them to be but the problem I'm having is how it changes the size of the dots:这将中断放在我想要的位置,但我遇到的问题是它如何改变点的大小:
I understand that I can change the size of the dots using binwidth and dotsize but changing it so the dots of group A are a reasonable size makes those in group C so small they can't even be seen.我知道我可以使用 binwidth 和 dotsize 更改点的大小,但是更改它以使 A 组的点具有合理的大小,这使得 C 组中的点变得如此之小,甚至看不到。 Is there any way I can change it so they are just all the same size.
有什么办法可以改变它,使它们的大小都一样。 Also is there a way I can change the size of the first section of the graph (0-10 on the y axis)?
还有一种方法可以更改图表第一部分的大小(y 轴上的 0-10)?
Perhaps a pseudo log scale:也许是一个伪对数刻度:
data.frame(
stringsAsFactors = FALSE,
Condition = c("A", "A", "A", "B", "B", "B", "C", "C", "C"),
Value = c(0L, 0L, 0L, 650L, 1600L, 900L, 85000L, 15000L, 60000L)
) %>%
ggplot(aes(x=Condition, y=Value, fill=Condition))+
geom_dotplot(binaxis = 'y', stackdir = "center", position=position_dodge(), dotsize = 1)+
scale_y_continuous(trans = scales::pseudo_log_trans(sigma = 0.1),
breaks = c(0, 10^c(0:6)),
labels = scales::label_number_si(accuracy = 1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.