标签: facet

将x和y轴添加到所有facet_wrap

通常希望最小化图中的墨水.我有一个刻面的情节(facet_wrap),并希望删除尽可能多的墨水,但保持可读性.我已按照我的意愿进行设置,除非在小平面(子图)中不存在x和y轴,除非在最左侧或底部.如此大量的墨水被移除,我相信眼睛需要这些暗示,并且正在询问如何将x和y轴放在a中的所有图中facet_wrap.下面是我的代码到目前为止,当前输出和所需的输出(红线是所需的加入):

library(ggplot); library(grid)

ggplot(mtcars, aes(mpg, hp)) + 
    geom_point() + 
    facet_wrap(~carb) +
    theme(panel.grid = element_blank(),
        panel.background = element_rect(fill = "white", colour = "black"), 
        panel.border = element_rect(fill = NA, colour = "white"), 
        axis.line = element_line(),
        strip.background = element_blank(),
        panel.margin = unit(2, "lines"))
Run Code Online (Sandbox Code Playgroud)

当前情节 在此输入图像描述

期望的情节 在此输入图像描述

r facet ggplot2 facet-wrap

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

不支持"Project facet Java 1.8版".在Eclipse Luna中

我正在使用最新的Eclipse Luna,它应该为Java 8做好准备.但是当我选择使用Tomcat 7创建一个新服务器并单击Next时,在Add and Remove屏幕中我无法移动我的项目,因为"Project" facet Java版本1.8不受支持." 有什么问题,如何解决这个问题?

eclipse facet tomcat7 java-8 eclipse-luna

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

在ggplot2中为每个facet_wrap网格放置一个图例

我有这个数据框:

        Date Server FileSystem PercentUsed
1  12/1/2011      A          /          60
2   1/2/2012      A       /var          50
3   2/1/2012      A        tmp          90
4  2/10/2012      A        /db          86
5  2/13/2012      A       /app          90
6  12/1/2011      B         C:          67
7   1/2/2012      B         D:          67
8   2/1/2012      B         F:          34
9  2/10/2012      B   /restore          89
10 2/13/2012      B         G:          56
11 12/1/2011      C          /          90
12  1/2/2012      C       /tmp          78
13  2/1/2012      C      /data          67
14 2/10/2012      C   /Storage          34
15 2/13/2012      C  /database          12 …
Run Code Online (Sandbox Code Playgroud)

r legend facet ggplot2 facet-wrap

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

图中的R ggplot2图例

所以,我有以下data.frame,我想在一个图中为yval与xval生成两个图,每个zval和类型tp.左撇子

> df
    xval         yval           se zval cond
1    1.0 1.831564e-02 1.831564e-03    0    a
2    1.2 2.705185e-02 2.705185e-03    0    a
3    1.4 3.916390e-02 3.916390e-03    0    a
4    1.6 5.557621e-02 5.557621e-03    0    a
5    1.8 7.730474e-02 7.730474e-03    0    a
6    2.0 1.053992e-01 1.053992e-02    0    a
7    2.2 1.408584e-01 1.408584e-02    0    a
8    2.4 1.845195e-01 1.845195e-02    0    a
9    2.6 2.369278e-01 2.369278e-02    0    a
10   2.8 2.981973e-01 2.981973e-02    0    a
11   3.0 3.678794e-01 3.678794e-02    0    a
12   3.2 4.448581e-01 4.448581e-02    0    a …
Run Code Online (Sandbox Code Playgroud)

r legend facet ggplot2

25
推荐指数
1
解决办法
1万
查看次数

R + ggplot2 =>在构面饼图上添加标签

我想在分面饼图上添加数据标签.
也许有人可以帮助我.

我的数据:

year <- c(1,2,1,2,1,2)
prod <- c(1,1,2,2,3,3)
quantity <- c(33,50,33,25,34,25)

df <- data.frame(year, prod, quantity)
rm(year, prod, quantity)
Run Code Online (Sandbox Code Playgroud)

码:

library(ggplot2)

# center's calculated by hand
centr2 <- c(16, 25, 49, 62.5, 81, 87.5)

ggplot(data=df, aes(x=factor(1), y=quantity, fill=factor(prod))) +
    geom_bar(stat="identity") +
    geom_text(aes(x= factor(1), y=centr2, label = df$quantity), size=10) +
    facet_grid(facets = .~year, labeller = label_value) +
    coord_polar(theta = "y")
Run Code Online (Sandbox Code Playgroud)

我的结果是:

馅饼炭

如果我删除coord_polar(theta ="y"),我将得到以下图:

酒吧情节

现在我很清楚,为什么我的数据标签不匹配.
但我不知道如何解决它.

我读到:
1.在饼图上放置标签
2. 在带有刻面密度的ggplot中添加文本
3. 饼图将其文本放在彼此的顶部

但没有找到答案.

r facet ggplot2 pie-chart

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

如何使用ggplot创建刻面线图?

我有一个使用此代码创建的数据框:

require(reshape2)
foo <- data.frame( abs( cbind(rnorm(3),rnorm(3, mean=.8),rnorm(3, mean=.9),rnorm(3, mean=1))))
qux <- data.frame( abs( cbind(rnorm(3),rnorm(3, mean=.3),rnorm(3, mean=.4),rnorm(1, mean=2))))
bar <- data.frame( abs( cbind(rnorm(3,mean=.4),rnorm(3, mean=.3),rnorm(3, mean=.9),rnorm(3, mean=1))))

colnames(foo) <- c("w","x","y","z")
colnames(qux) <- c("w","x","y","z")
colnames(bar) <- c("w","x","y","z")

rownames(foo) <- c("n","q","r")
rownames(qux) <- c("n","q","r")
rownames(bar) <- c("n","q","r")

foo <- cbind(ID=rownames(foo),foo)
bar <- cbind(ID=rownames(bar),qux)
qux <- cbind(ID=rownames(bar),qux)

foo$fn <- "foo"
qux$fn <- "qux"
bar$fn <- "bar"

alldf<-rbind(foo,qux,bar)
alldf.m <- melt(alldf)
Run Code Online (Sandbox Code Playgroud)

我想要做的是创建一个facet格式的ggplot线条曲线,所以它创建一个如下图形:

在此输入图像描述

实际图形不包含向上线 - 这只是一个草图,因此线条分离是清晰的.

我当前的代码不起作用:

    library(ggplot2)
    p <- ggplot(data=alldf.m, aes(x=variable)) …
Run Code Online (Sandbox Code Playgroud)

curve r facet ggplot2

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

ggplot,facet,piechart:将文本放在饼图切片的中间

我正在尝试使用ggplot生成一个刻面的饼图,并面临在每个切片中间放置文本的问题:

dat = read.table(text = "Channel Volume Cnt
                         AGENT   high   8344
                         AGENT medium   5448
                         AGENT    low  23823
                         KIOSK   high  19275
                         KIOSK medium  13554
                         KIOSK    low  38293", header=TRUE)

vis = ggplot(data=dat, aes(x=factor(1), y=Cnt, fill=Volume)) +
  geom_bar(stat="identity", position="fill") +
  coord_polar(theta="y") +
  facet_grid(Channel~.) +
  geom_text(aes(x=factor(1), y=Cnt, label=Cnt, ymax=Cnt), 
            position=position_fill(width=1))
Run Code Online (Sandbox Code Playgroud)

输出: 在此输入图像描述

geom_text应该调整哪些参数才能将数字标签放在饼图切片的中间?

相关问题是Pie plot将其文本放在彼此的顶部,但它不处理facet的情况.

更新:在上面的问题中遵循Paul Hiemstra的建议和方法我改变了代码如下:

---> pie_text = dat$Cnt/2 + c(0,cumsum(dat$Cnt)[-length(dat$Cnt)])

     vis = ggplot(data=dat, aes(x=factor(1), y=Cnt, fill=Volume)) +
     geom_bar(stat="identity", position="fill") +
     coord_polar(theta="y") +
     facet_grid(Channel~.) +
     geom_text(aes(x=factor(1), 
--->               y=pie_text, 
                   label=Cnt, ymax=Cnt), …
Run Code Online (Sandbox Code Playgroud)

visualization r facet ggplot2 pie-chart

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

ggplot2:将多变量facet_wrap标签放在一行上

我使用facet_wrap将我的散点图分割为

facet_wrap(x~y+z)
Run Code Online (Sandbox Code Playgroud)

根据需要,这会在我的案例中生成22个图.但是,这22个图中的每一个的标签显示为3行(x,y和z),这不必要地消耗窗口中的空间并将图块拼成一个小区域.我宁愿希望我的情节更大.由于变量y和z很短,我想将它们显示在同一行而不是两行中.

我查看了贴标机选项,但它们似乎都没有做我想要的.我很感激这里有任何建议.

r facet ggplot2 facet-wrap

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

像facet_grid中的facet_wrap中设置"space"

我需要不同宽度的方面; 左图显示实验的动态范围,右图显示测试条件.有没有办法让facet_wrap有自由x和y标度?它可以在facet_grid中使用,但即使scale ="free",也有一个固定的y标度.facet_wrap允许自由y比例,但x比例似乎是固定的.几年前在谷歌页面上发布了同样的问题,但答案并不令人满意. https://groups.google.com/forum/#!topic/ggplot2/1RwkCcTRBAw

对不起,如果这也是重复的话; 任何帮助将非常感激!

mdf <- read.table(text="
   strain val     type
1       1 0.0000  sample
2       1 0.0140  sample
3       1 0.0175  sample
4       2 0.0025  sample
5       2 0.0260  sample
6       2 0.0105  sample
7       3 0.0190  sample
8       3 0.0725  sample
9       3 0.0390  sample
10      4 0.0560  sample
11      4 0.0695  sample
12      4 0.0605  sample
13      5 0.0735  sample
14      5 0.1065  sample
15      5 0.0890  sample
16      6 0.1135  sample
17      6 0.2105  sample …
Run Code Online (Sandbox Code Playgroud)

r facet ggplot2

17
推荐指数
2
解决办法
4027
查看次数

摆脱那些灰色框上的facet_grid标签?

我想要的是删除右侧的标签,侧面的灰色框上的标签.我举个例子:

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p + facet_grid(cyl ~ .)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

提前致谢!

胡安

plot label r facet ggplot2

16
推荐指数
1
解决办法
1万
查看次数