11/26/2022 0 Comments Sigmaplot 11, double y axis![]() Grid.arrange(testplot2, testplot1, ncol = 2)īut I want it to be arranged like this, where the XX and YY plots from above are normalized in size with the other plots (this was done using individual plots, and using plot_grid):Įxample data from a larger set: test.data <- structure(list(Station = structure(c(1L, 1L, 1L, 1L, 2L, 2L,ĢL, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,ĢL, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,ĢL, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,ĢL, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L). Theme(legend.position = "top", legend.title = element_blank()) +įacet_wrap( ~ constituent, ncol = 1, scales = "free_y") Labs(x = "Station", y = "Unit b", shape = "Sampling Quarter", fill = "Species") + Geom_point(aes(shape = factor(quarter), fill = Species)) Testplot2 <- ggplot(test.data2, aes(Station, value)) + Guides(fill = guide_legend(override.aes = list(shape = 21), nrow = 2, byrow = TRUE), shape = guide_legend(nrow = 2, byrow = TRUE)) +įacet_wrap( ~ constituent, ncol = 3, scales = "free_y") Theme(legend.position = "none", legend.title = element_blank()) + Labs(x = "Station", y = "Unit a", shape = "Sampling Quarter", fill = "Species") + Geom_point(aes(shape = factor(quarter), fill = Species)) + Testplot1 <- ggplot(test.data1, aes(Station, value)) + I'm trying to use this code (just copy the example data below, and run): library(ggplot) One label would be centered on the two leftmost plots, and one centered on the left of the next column of 4 plots. This presents the plots how I'd like them arranged, but I can't figure out how to have two y-axis labels, due to different units. My next thought was to create each plot individually, then arrange them in a grid using cowplot. My original plan was to have two separate facets made using facet-wrap, and combine those, however, this doesn't maintain the 4x4 arrangement, it transforms it into a 1x2, which ruins alignment of plots and shrinks the larger faceted grid. It is 4x4 grid of plots, with the first two rows of the first column are empty, to allow for the placement of the legend. ![]() The issue is I'm trying to replicate a figure done in SigmaPlot. I want quarter differentiated with shapes, and species with colors. Station will be on the x-axis, value on the y-axis, and the constituent will be used with the facet_wrap. ![]() My data have 2 factors, quarter and species. I have been struggling with ggplot to display these plots how I would like. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |