Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

0 votes
0 answers
246 views

Create a custom legend for facet_grid() variables

I am using ggplot2 to create a heatmap, and am grouping my y variable by a categorical variable using facet_grid(). My y variables are genes of interest, and I am grouping them by their respective ...
Linton's user avatar
  • 45
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 ...
Constance Coubris's user avatar
2 votes
1 answer
306 views

Add a main legend for colored line types on ggplot2 facet_wrap plot

How can I add a main common legend to suitable blank area for facet_wrap plot? I need 3 line types with 3 different colors in the legend. (black dotted line: Current Price, green dotted line: lowline, ...
Serhat Akay's user avatar
0 votes
0 answers
759 views

create separate legend for each row of facet_grid

I am using nested_facet() to plot a large number of experiments, yielding a 9x6 array. Each panel in the array is a stacked bargraph with variables indicated by color, same set of variables common to ...
Timmo83's user avatar
  • 169
1 vote
1 answer
3k views

Rename Legend title on facet_wrap [duplicate]

I have a facet wrap of 8 plots and I want to rename the Legend, it currently defaults to the fill value Depth_bins but I want to be able to change that. I've tried various methods, including the below ...
R student's user avatar
  • 109
3 votes
1 answer
2k views

ggplot2 - facet_wrap with individual legends

I am using ggplot2 to plot maps that have the same extent (i.e. same spatial coverage) but that show different features. This is how it looks like: library(raster) library(reshape2) library(ggplot2) #...
thiagoveloso's user avatar
  • 2,671
1 vote
0 answers
1k views

separate legend in groups with facet_wrap ggplot

Please find a reprex below but this is what I currently have: I don't need to have a separate legend for each of the plots but I would like the legend to be divided by the facets. It can just be by ...
InesGuardans's user avatar
0 votes
2 answers
2k views

Adding a legend to ggplot2 facets with multiple lines?

I have got a problem with my ggplot for faceted multiple line plots for seven metropolitan regions in South Korea. The structure of my csv dataset is just similar to a panel data with both cross-...
Xaviermoros's user avatar
0 votes
2 answers
567 views

Mismatched linetypes in plot and legend

I plot this data using the following code df = read.csv(file = "data.csv"); p = ggplot(data = df) + geom_line(aes(x=x,y=yp,linetype="dashed")) + geom_line(aes(x=x,y=yi,linetype="solid")) + ...
Dariusz's user avatar
2 votes
1 answer
3k views

Display the legend inside the graph when wrapping with ggplot2

How can I do... ... instead of the default ... ?
Arthur's user avatar
  • 1,228
1 vote
1 answer
636 views

R ggplot2 Remove space between legends dual axis plot

I have two graphs that I'm trying to merge with dual y axes. I'm having trouble getting rid of that space between the two legends that I am trying to merge. Here are my two graphs: require(ggplot2) ...
alki's user avatar
  • 3,494
34 votes
5 answers
29k views

Place a legend for each facet_wrap grid in ggplot2

I have this data frame: x <- data.frame( Date = factor(rep( c("12/1/2011", "1/2/2012", "2/1/2012", "2/10/2012", "2/13/2012"), 3 )), ...
user1471980's user avatar
  • 10.5k