yaxis

Multiple y axis for bar plot and line graph using ggplot

若如初见. 提交于 2019-11-26 21:53:30
问题 I have some transpiration data from an experiment that I would like to show as a time series on a line graph using R. I also have some precipitation data which I would like to show on the same graph as a bar plot. I've been able to do this using R's base program, but I'd like to do this in ggplot. I've searched everywhere and I know that the designers aren't too fond of making graphs this way so it's tough, but I have seen it done with multiple line graphs/scatter plots using two y axis. Can

Combining Bar and Line chart (double axis) in ggplot2

你离开我真会死。 提交于 2019-11-26 12:40:45
问题 I have double-y-axis chart made in Excel . In Excel it requires only basic skills. What I\'d like to do is to replicate this chart using the ggplot2 library in R . I have already done this, but I need to plot Response on 2nd-y-axis . I enclose reproducible code I\'ve used: #Data generation Year <- c(2014, 2015, 2016) Response <- c(1000, 1100, 1200) Rate <- c(0.75, 0.42, 0.80) df <- data.frame(Year, Response, Rate) #Chart library(ggplot2) ggplot(df) + geom_bar(aes(x=Year, y=Response),stat=\

How can I plot with 2 different y-axes?

不想你离开。 提交于 2019-11-25 23:33:36
问题 I would like superimpose two scatter plots in R so that each set of points has its own (different) y-axis (i.e., in positions 2 and 4 on the figure) but the points appear superimposed on the same figure. Is it possible to do this with plot ? Edit Example code showing the problem # example code for SO question y1 <- rnorm(10, 100, 20) y2 <- rnorm(10, 1, 1) x <- 1:10 # in this plot y2 is plotted on what is clearly an inappropriate scale plot(y1 ~ x, ylim = c(-1, 150)) points(y2 ~ x, pch = 2)