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?
Flipped histogram with count going left rather than right
I need to graph a flipped histogram (i.e. count on x-axis, values on y) but with the count ascending to the left rather than the right
r – ggplot2 geom_errorbar with solid whisker lines and position dodged
I am trying to create a line plot and have one of the groups use a dotted line type. Unfortunately the whiskers can be hard to see with dotted lines so I am trying to add solid lines for the whiskers.
Dynamic aes() labels for fixed breaks in vertical facet_grid [closed]
Closed last month.
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):
Horizontal axis title on top after coord_flip
I’ve been trying for a while now to put the horizontal axis title on top of the chart after using coord_flip()
in ggplot2, but without any success.
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 […]