All Questions
75
questions
2
votes
1
answer
47
views
R ggplot2 need custom legend to have less values than corresponding line plot values to avoid duplicates
I have data which looks like the following:
library(tidyverse)
library(RColorBrewer)
dat<-tibble(
group = c(rep("Group 1", 10), rep("Group 2", 10), rep("Group 3", ...
0
votes
1
answer
29
views
Variable legend outlined in appropriate color, but filled with black dot
I have used ggplot in R to generate a dot plot with three "samples" (Adipocytes, BAT and WAT) which are colored by ""group". The plot is correct, but the "group" ...
0
votes
1
answer
36
views
One variable with three colors, but only one color on the legend
I have two variables in my table. I want one of them to appear with three colors on the graph, but only one color on the legend. How can I remove the NAs, which don't correspond to separate variables, ...
1
vote
1
answer
86
views
ggplot: How to drop certain factor level from legend while still be able to set its colour?
I need do make density plots of the age of the workers of a company. One density plot shall show age of all workers and the other split by sex. It is something like this:
# Load libraries.
library(...
1
vote
1
answer
351
views
ggplot2 transparent/white legend key with stat_ellipse
I've got a plot where I'm using stat_ellipse to show 95% confidence ellipses around some points. I'd like to get rid of the grey background behind the points in the legend, but it's just not working. ...
0
votes
0
answers
66
views
ggplot2 line always pink in R
I am trying to create some vizualizations with ggplot2 in R but the colors don't match what is in my code and the legend. One line is always pink.
Here is my code:
point = format_format(big.mark = &...
0
votes
0
answers
19
views
How to add a legend on a plot with multiple dataset with ggplot2 through R? [duplicate]
gfg_plot <- ggplot(NULL, aes(x = Area, y = Richness, fill = District )) +
geom_point(data=District1, col="blue") +
geom_point(data=District2, col="black")+
geom_point(data=...
0
votes
1
answer
42
views
Not identical color between legend and histogram with ggplot
I would like to have different panels of colors depending on the species class.
I managed to change the legend correctly to have the right color panel for each class.
The problem is: the colors in the ...
0
votes
1
answer
114
views
is ggplot confused? It exchanges the color labels [duplicate]
I'm drawing density plot with ggplot, but in the output it inverts the name of the colors!
This is my script:
ggplot(dataset) +
geom_density( aes( x = `Real Wage 1`, fill = "red"), alpha =...
1
vote
0
answers
179
views
ggplot2: How to change the names and the values in the legend
I'm drawing a geographical map of my country using ggplot2.
Actually, I've got what I was looking for, but I want something more in the legend.
I have a dataset like this:
City Name Nominal Wage ...
0
votes
1
answer
37
views
Changing the fill colour in a stacked barchart in ggplot2
I have a very simple question.
I need to add a legend and change the colour of the bars in a stacked barchart.
I managed to split my barchart into three different colour groups according to the year ...
0
votes
1
answer
57
views
Combine fill and color legend in ggplot
I have found some Questions similar to my issue, but none that really fit.
I have 4 data columns I want to plot, 3 as lines and 1 as area.
I'd like to condense the Legend of the resulting Plot into a ...
0
votes
1
answer
359
views
ggplot2 legend showing but variables in plot don't have colour
I have been working on some code to plot a graph with multiple variables with a secondary Y axis and legend. I achieved this far with the examples below:
ggplot2 line chart gives "geom_path: Each ...
1
vote
1
answer
141
views
Convert an vector to a specific color for `plot()`
Below is a minimal working example.
library(ggplot2)
set.seed(926)
df <- data.frame(x. = rnorm(100),
y. = rnorm(100),
color. = rnorm(100))
library(ggplot2)
p <...
0
votes
1
answer
308
views
Reverse legend in geom_contour
I'm struggling to find the right solution to reverse the legend, so that red is at the bottom and greens at the top. Here's a simple example.
library(ggplot2)
library(dplyr)
x = seq(0.01,1,0.01)
y = ...