# Create a column that is Ukraine or other Then put this data in long form # Pivot longer That gives a data frame that looks like this Date Latvia Lithuania Poland Russian Federation Ukraine You can pivot your data longer, and use facet_wrap like this.
How to plot a graph in excel with two y axis code#
I'm not good at 'gtable' package of R and would appreciate any support in correcting my code (or workflow) so that to finally build this chart and enhance my programming skills in R. I got the following error in the following line of the code: g <- gtable_add_grob(g, ax, pp$t, length(g$widths) - 1, pp$b)Įrror: grobs must either be a single grob or a list of grobs Gtable:::cbind_gtable(leg1, leg2, "first") Leg = gtable:::cbind_gtable(leg1, leg2, "first") G <- gtable_add_grob(g, ax, pp$t, length(g$widths) - 1, pp$b) G <- gtable_add_cols(g, g2$widths$l], length(g$widths) - 1) G <- gtable_add_grob(g1, g2$grobs], pp$t, Pp <- c(subset(g1$layout, name = "panel", se = t:r)) # overlap the panel of 2nd plot on that of 1st plot G2 <- ggplot_gtable(ggplot_build(p3.2right)) G1 <- ggplot_gtable(ggplot_build(p3.2left)) And finally I used the code that worked nicely before (but for some reasons stopped working now) that did what I need - put 2 plots on one chart:.Scale_x_date(date_labels = "%Y", date_breaks = "1 year") + Then - for data points for the secondary Y axis:.Legend.background = element_rect(fill = "transparent", colour = NA), Panel.background = element_rect(fill = NA),Ī = element_line(colour= "#ABABAB"),Ī = element_text(size = 5, angle = 90, colour = "black", margin = margin(t = 0, r = 0, b = 0, l = 0)), 5, size = 5, colour = "black"),Ī = element_text(size = 5, colour = "black"), I use the following part of the code to read and prepare the data for the chart: data points for Latvia, Lithuania, Poland and Russia on one Y axis,.