Relative Content

Tag Archive for rggplot2

How can I add a legend to a ggplot when there is not an aesthetic? [duplicate]

This question already has answers here: How to add a legend to ggplot in R? (1 answer) Add legend to ggplot2 line plot (4 answers) Closed last month. library(tidyverse) df1 <- tibble(wt=4, mpg=25) df2 <- tibble(wt=2, mpg=15) ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + geom_point(data=df1, aes(x=wt, y=mpg), color=”red”, size=3) + geom_point(data=df2, aes(x=wt, y=mpg), color=”blue”, size=3) Is […]

Overlaying discrete and continuous versions of the same variable in ggplot

I have a dot graph where points defined by colours on a continuous colour scale based on the value of one variable, bout I also want to graph grouped smooth lines over the top of this dot graph. The groups for the smooth lines will be discretized versions of the variable that the continuous dot graph is based on.

inconsistent results in ggplot

I’m making two volcano plots using ggplot and the parameters in both of them are the same except for the legend. However, the font size of the legends is different between the two plots. How can I fix this?

R, ggplot2: How to get same X axis unit scale?

How can I use the same “X axis scale” for multiple plots using R and ggplot2?
i.e. given the following two plots, I want the second one to be twice as wide as the first one, as it has twice as many bars (limits can be different, but “unit step” should have same real length, as well as bar size):

R Plot not showing if inside function [duplicate]

This question already has an answer here: ggplot2 does not appear to work when inside a function R [duplicate] (1 answer) Closed 2 years ago. If I run the following code, everything works as expected and the plot shows on the right panel in RStudio: plot(x=iris$Sepal.Width, y=iris$Sepal.Length) However, if instead I call the plot from […]

R Plot not showing if inside function [duplicate]

This question already has an answer here: ggplot2 does not appear to work when inside a function R [duplicate] (1 answer) Closed 2 years ago. If I run the following code, everything works as expected and the plot shows on the right panel in RStudio: plot(x=iris$Sepal.Width, y=iris$Sepal.Length) However, if instead I call the plot from […]