相关疑难解决方法(0)

ggplot2:在分面条形图中删除未使用的因子,但在构面之间没有不同的条宽

df <- structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 
5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L), .Label = c("1", 
"2", "3", "4", "5", "6", "7"), class = "factor"), TYPE = structure(c(1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 
1L, 2L, 3L, 4L, 5L, 6L, 1L, …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

17
推荐指数
3
解决办法
6666
查看次数

如何在gridExtra中控制绘图宽度?

可能重复:
左对齐两个图形边(ggplot)

我试图ggplot在同一页面上,顶部和底部放置两个图,以便它们的宽度相同.数据来自相同的时间序列,x轴是时间,因此重要的是具有相同时间的数据点不会相对于彼此水平移位.我尝试grid.arrange从包gridExtra:

grid.arrange(p1, p2)
Run Code Online (Sandbox Code Playgroud)

但由于y轴标签的宽度不同,图表的宽度不同.我查看了这篇涉及类似问题的帖子,但我无法应用这些信息来解决我的问题.

在此输入图像描述

r ggplot2 gridextra

7
推荐指数
2
解决办法
2万
查看次数

R:由于UseMethod("getModelInfo",model)中的错误,多行不能正常工作

在R中,我准备了多个ggplot2数字,保存到这样的变量:

flashplot <- ggplot(flash, aes(x=flash$Year, y=flash$Proc)) 
+ stat_smooth(method="lm", formula = "flash$Proc ~ poly(flash$Year, 2, raw=TRUE)", n=14, level=0.9) 
+ geom_point(shape=19) + ylab("Percentage of total existing versions") 
+ xlab("Years of Existence") + scale_x_continuous(breaks = c(0,2,4,6,8,10,12,14,16,18,20))
Run Code Online (Sandbox Code Playgroud)

绘制单个图形按预期工作,但我想使用多色图绘制4个数字(2乘2),如R cookbook中所述.

当我收到错误时,我尝试了食谱中的例子,我应该会这样做,但它给了我同样的错误:

> multiplot(p1, p2, p3, p4, cols=2)
Error in UseMethod("getModelInfo", model) : 
  no applicable method for 'getModelInfo' applied to an object of class "c('gg', 'ggplot')"
Run Code Online (Sandbox Code Playgroud)

我,使用R 2.15.2在Windows 7下,和最新的软件包ggplot2coefplot:

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit) …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

3
推荐指数
1
解决办法
8989
查看次数

标签 统计

ggplot2 ×3

r ×3

gridextra ×1