延长X轴区间ggplot2
Extend X axis interval ggplot2
我正在尝试绘制具有大量 X 轴值的数据。我试图不与 geom_point 重叠我的观点。我发现有很多关于 "scale_x_continuous"、"position = jitter or dodge" 等的讨论...每次我的问题仍然存在,因为我需要保持观点一致。而且,"scale_size_area"并没有使它变得好。
编辑:生成的数据在 post 结束时已经融化。
我不能post图像(Link to image),但给出了这个想法:我在我的Y轴上有6个级别,在X轴上有400个级别。我的点(shape = 1 = circle)是 Y-levels 对齐的,并且根据值具有不同的直径。
没问题,但是圆圈重叠了。
plot <- ggplot(data, aes(x_variable_400_levels, y_variable_6_levels)) +
# value*100 because values are between 0 and 1 to have bigger circles
geom_point(shape = 1, size = data$value*100) +
# theme description
theme(
plot.title = element_text(lineheight=.8, face="bold", vjust=1),
axis.title.x = element_text(vjust=-0.5),
axis.title.y = element_text(vjust=0.3)
)
所以,我的问题是:我可以修改X轴两个值之间的间隔以避免圆之间的重叠吗?抖动在这里并不有趣,因为噪声不允许很好地可视化数据,包括当我尝试只有水平噪声时的数据。
任何类型的解决方案、链接或其他教程都将不胜感激。
编辑:生成的数据。使用 read.table、sep = "," 和 header = T 导入。重点是,我的圈子很小,但它们也很重要。
data <- read.table(text='"trf","sample","value"
36,"S1",0.143882104
38,"S1",0.025971979
47,"S1",0.016711593
56,"S1",0.027896069
67,"S1",0.025870577
93,"S1",0.07638307
100,"S1",0.022905895
102,"S1",0.019192547
104,"S1",0.018258923
107,"S1",0.005032219
114,"S1",0.028297368
123,"S1",0.007874848
131,"S1",0.024184004
36,"S2",0.115123666
38,"S2",0
47,"S2",0.00479275
56,"S2",0.029523128
67,"S2",0.030133055
93,"S2",0.044749246
100,"S2",0.032865979
102,"S2",0
104,"S2",0
107,"S2",0.013160255
114,"S2",0.052047248
123,"S2",0.007632445
131,"S2",0
36,"S3",0.179332128
38,"S3",0.046215267
47,"S3",0
56,"S3",0.070791832
67,"S3",0.050214857
93,"S3",0.074108014
100,"S3",0
102,"S3",0
104,"S3",0
107,"S3",0
114,"S3",0.081441849
123,"S3",0
131,"S3",0.100090456', header=T,sep=",")
我不认为更改间隔是解决方案,因为您的 x 轴是数字。如果实例 1 和 2 之间的 space 比 9 和 10 之间的 space 更大,则将更难以解释。如果您将所有间隔更改为最大的圆,则该图将是太宽了。我还认为,如果您有更多数据,它会变得非常混乱,这使得更难看到模式。也许(多面的)条形图是解决方案?允许水平和垂直比较,小的值是可见的,并且很容易提取和比较值。这是一个开始:
p2 <- ggplot(data, aes(x=trf, y=value))+
geom_bar(stat="identity") +
facet_grid(sample~.) +
xlim(c(0,150)) + theme_bw()
我正在尝试绘制具有大量 X 轴值的数据。我试图不与 geom_point 重叠我的观点。我发现有很多关于 "scale_x_continuous"、"position = jitter or dodge" 等的讨论...每次我的问题仍然存在,因为我需要保持观点一致。而且,"scale_size_area"并没有使它变得好。
编辑:生成的数据在 post 结束时已经融化。
我不能post图像(Link to image),但给出了这个想法:我在我的Y轴上有6个级别,在X轴上有400个级别。我的点(shape = 1 = circle)是 Y-levels 对齐的,并且根据值具有不同的直径。
没问题,但是圆圈重叠了。
plot <- ggplot(data, aes(x_variable_400_levels, y_variable_6_levels)) +
# value*100 because values are between 0 and 1 to have bigger circles
geom_point(shape = 1, size = data$value*100) +
# theme description
theme(
plot.title = element_text(lineheight=.8, face="bold", vjust=1),
axis.title.x = element_text(vjust=-0.5),
axis.title.y = element_text(vjust=0.3)
)
所以,我的问题是:我可以修改X轴两个值之间的间隔以避免圆之间的重叠吗?抖动在这里并不有趣,因为噪声不允许很好地可视化数据,包括当我尝试只有水平噪声时的数据。
任何类型的解决方案、链接或其他教程都将不胜感激。
编辑:生成的数据。使用 read.table、sep = "," 和 header = T 导入。重点是,我的圈子很小,但它们也很重要。
data <- read.table(text='"trf","sample","value"
36,"S1",0.143882104
38,"S1",0.025971979
47,"S1",0.016711593
56,"S1",0.027896069
67,"S1",0.025870577
93,"S1",0.07638307
100,"S1",0.022905895
102,"S1",0.019192547
104,"S1",0.018258923
107,"S1",0.005032219
114,"S1",0.028297368
123,"S1",0.007874848
131,"S1",0.024184004
36,"S2",0.115123666
38,"S2",0
47,"S2",0.00479275
56,"S2",0.029523128
67,"S2",0.030133055
93,"S2",0.044749246
100,"S2",0.032865979
102,"S2",0
104,"S2",0
107,"S2",0.013160255
114,"S2",0.052047248
123,"S2",0.007632445
131,"S2",0
36,"S3",0.179332128
38,"S3",0.046215267
47,"S3",0
56,"S3",0.070791832
67,"S3",0.050214857
93,"S3",0.074108014
100,"S3",0
102,"S3",0
104,"S3",0
107,"S3",0
114,"S3",0.081441849
123,"S3",0
131,"S3",0.100090456', header=T,sep=",")
我不认为更改间隔是解决方案,因为您的 x 轴是数字。如果实例 1 和 2 之间的 space 比 9 和 10 之间的 space 更大,则将更难以解释。如果您将所有间隔更改为最大的圆,则该图将是太宽了。我还认为,如果您有更多数据,它会变得非常混乱,这使得更难看到模式。也许(多面的)条形图是解决方案?允许水平和垂直比较,小的值是可见的,并且很容易提取和比较值。这是一个开始:
p2 <- ggplot(data, aes(x=trf, y=value))+
geom_bar(stat="identity") +
facet_grid(sample~.) +
xlim(c(0,150)) + theme_bw()