facet-wrap

add “floating” axis labels in facet_wrap plot

穿精又带淫゛_ 提交于 2019-11-26 15:14:21
I have the same problem as this user - I have a 'jagged' faceted plot, in which the bottom row has fewer panels than the other rows, and I would like to have x-axis ticks on the bottom of each column. The suggested solution for that problem was to set scales="free_x" . (In ggplot 0.9.2.1; I believe the behavior I'm looking for was default in earlier versions.) That's a poor solution in my case: my actual axis labels will be rather long, so putting them under each row will occupy too much room. The results are something like this: x <- gl(3, 1, 15, labels=paste("this is a very long axis label "

geom_tile and facet_grid/facet_wrap for same height of tiles

巧了我就是萌 提交于 2019-11-26 14:31:40
问题 Using ggplot, I would like represent a graph tile with panel, but with same height tile for each panel. I have this graph : dataSta <- list(sites=rep(paste("S", 1:31),each=12), month=rep(1:12,31), value=round(runif(31*12, min=0, max=3000)), panel=c(rep("Group 1",16*12),rep("Group 2", 12*12), rep("Group 3", 3*12))) library(ggplot2) library(grid) base_size <- 9 windows() ggplot(data.frame(dataSta), aes(factor(month), sites)) + geom_tile(aes(fill = value), colour = "black")+ facet_wrap(~panel,

ggplot2: Changing the order of stacks on a bar graph

♀尐吖头ヾ 提交于 2019-11-26 09:57:05
问题 I\'m trying to make a stacked bar graph with a facet_wrap, but I want the order of my stacked variables (\"developed\") to be flipped. I\'ve reordered the factors, and tried \"order=descend(),\" as well as \"scale_fill_manual\" and nothing seems to work. Here is my code: developed=rep(c(\"developed\",\"available\"),6) agriculture=rep(c(rep(\"loi\",2), rep(\"dryland\",2), rep(\"agroforestry\",2)),2) acres=c(7435,24254,10609,120500,10651,75606,6037,9910,4390,895,9747,46893) islands=c(rep(\"All

Setting absolute size of facets in ggplot2

我只是一个虾纸丫 提交于 2019-11-26 08:26:08
问题 I\'m creating several facetted plots for a report. The number of facets varies between 2 and 8. Ideally, I\'d like the absolute size of each facet (across plots) to be the same (e.g. 4x4 cm) so that it is easier to compare them (and it looks nicer, too). Is that possible? df1 <- structure(list(group1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,1L, 1L, 1L, 1L, 1L), .Label = c(\"S1\", \"S2\"), class = \"factor\"), group = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c(\"A\

ggplot2: facet_wrap strip color based on variable in data set

主宰稳场 提交于 2019-11-26 07:59:47
问题 Is there a way to fill the strips of facets created with facet_wrap based on a variable supplied with the data frame? Example data: MYdata <- data.frame(fruit = rep(c(\"apple\", \"orange\", \"plum\", \"banana\", \"pear\", \"grape\")), farm = rep(c(0,1,3,6,9,12), each=6), weight = rnorm(36, 10000, 2500), size=rep(c(\"small\", \"large\"))) Example plot: p1 = ggplot(data = MYdata, aes(x = farm, y = weight)) + geom_jitter(position = position_jitter(width = 0.3), aes(color = factor(farm)), size =

Place a legend for each facet_wrap grid in ggplot2

纵然是瞬间 提交于 2019-11-26 07:31:37
问题 I have this data frame: 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 dput(x) structure(list(Date = structure(c(2L, 1L, 3L, 4L, 5L, 2L, 1L, 3L, 4L, 5L, 2L, 1L, 3L, 4L, 5L), .Label

add “floating” axis labels in facet_wrap plot

半城伤御伤魂 提交于 2019-11-26 04:19:23
问题 I have the same problem as this user - I have a \'jagged\' faceted plot, in which the bottom row has fewer panels than the other rows, and I would like to have x-axis ticks on the bottom of each column. The suggested solution for that problem was to set scales=\"free_x\" . (In ggplot 0.9.2.1; I believe the behavior I\'m looking for was default in earlier versions.) That\'s a poor solution in my case: my actual axis labels will be rather long, so putting them under each row will occupy too