Dear all,
I am running R 3.3.2 on Windows (64bit), and ggplot2 2.2.0. Here is the plot I generate:
my.data <- structure(list(
Category = c(
"Very long Category Name",
"Very long Category Name",
"Very long Category Name",
"Very long Category Name",
"Category 2",
"Category 2",
"Category 2",
"Category 2"
),
x = c(1, 2, 3, 4,
1, 2, 3, 4),
y = c(10, 12, 14, 16, 15, 13, 11, 9)
), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -8L), .Names = c("Category", "x", "y"))
p <- ggplot(my.data, aes(x = x, y = y))
p <- p + geom_bar(stat = "identity")
p <- p + facet_grid(Category ~ ., switch = "y")
p <- p + theme_bw()
p <- p + theme(strip.text.y = element_text(angle = 180),
strip.background = element_rect( fill = "white", colour = "white"))
print(p)
You can see that the y axis is to the left of the category names, which looks weird. In previous versions of ggplot2, when using the switch = "y" argument, the order was "Category Name" -> "Axis" -> "Plot".
Any idea how to switch the position of the y-axis with the category facet?
Thanks!
Marcel