I have created a conspiracy similar to three different groups in my data such as:
df & lt; - data.frame (x = representative (seq (0.05,1, = 0.05), time = 40), y = sample (c ('a', 'b'), 20 * 40, per = true), id = Representative (1:40, each = 20), Group = C (Rep (1,20 * 12), Representative (2,20 * 12), Representative (3, 20 * 16)) G1 and LT; - GG Plot (DF [DF $ Group == 1,], AES (X, Y, Group = ID)) G1 and LT; - G1 + GOML Line (G1) and LT; - G1 + Faset_Wapper (~ ID, NACL = 3) G2 and Lt; - ggplot (df [df $ group == 2,], aes (x, y, group = id)) g2 and lt; - g2 + geom_line () g2 and lt; - g2 + facet_wrap (~ id, nocl = 3) g3 and lt; - GG Plot (DF [DF $ Group == 3,] AES (X, Y, Group = ID) G3 and LT; - G3 + GOML Line (G3) and LT; - Grid 3 + FAP_Wapper (~ Id, ncol = 3) (E.g. g1, g2, g3, nrow = 1)
gives me this:
As you can see, the number of aspects is different between the three groups, which means that in the three columns in the aspects Is there a different height that is to match this height in a non-delicate way (i mean to define the heights of columns 2 and 3, tell me such an aspect, as if they seem to have Is the equally high altitude)?
.
Library (ggplot2) library (gridExtra) ncol = 3 df & lt; - data.frame (x = representative (seq (0.05,1, level = c ("a", "b")), = = (c = (0.05), times = 40), y = factor (sample (c) ('A', 'B'), 20 * 40, Place = TRUE) ID = Representative (1:40, every = 20), Group = C (Rep (1,20 * 12), Representative (2,20 * 12), rectangle (3, 20 * 16)) max_cases & lt; max (table (unique (df [, c ("id", "group")]) $ group # Create the Phantom plot for everything in # rect_dim & lt; - roof (max / CNC) * ncol plot & lt; - lapply (x = unique (d) F $ group), FUN = function (i) {df_case & lt; - subset (df, subset = group == i) totaling and lt; - no (unique (df_case [, c ("id", "group") ]) # Plates fill_levels to create fill level for pad & lt; - list (sloppy (x = 1: (rect_dim - tot_case), function (y) {paste0 (rep (x = "", times = y), collapse Df_case $ id.label & lt; - given order (df_case $ id, level = C (unique (df_case $ id), fill_levels)) g_case & lt; - ggplot (df_case, aes (x , Y, group = id.label)) + geom_line () + facet_wrap (~ id.label, ncol = ncol, drop = falls) # To whiten white wires, clean it slightly (i! = 1) {g_case & lt; -g_case + theme (axis.text.y = element_text (color = "white"), pivot .title.y = element_text (color = "white"), axis.ticks.y = element_line (color = "white")} } G_case & lt; - ggplotGrob (g_case) rm_me & lt; - (tot_case: rect_dim) [-] # Paste% empty panel and layout gccage $ gras (% c_case $ grobs)% c in% c (paste 0 ("panel" , Rm_me), paste 0 ("strip_t.", Rm_me))] <- faucet g_case $ layout <- g _case $ layout! [G_case $ layout $ name %% c (paste 0 ("panel-" , Rm_me), paste 0 ("strip_t-", rm_me)),] g_case}) Plots $ nrow = 1 do.call ("grid.", Plot)
Comments
Post a Comment