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

All Questions

Tagged with
342 questions with no upvoted or accepted answers
5 votes
1 answer
330 views

How can I make a cyclic, donut-like color legend in ggplot?

CONTEXT I have some data that looks like this: val = 0:100 sample_data = data.frame( t=val, px=cos(2*pi*val/100), py=sin(2*pi*val/100), v_angle = (val*360/100 + 90) %% 360 ) I am ...
Max Candocia's user avatar
  • 4,417
5 votes
0 answers
350 views

Legend is displaying additional shape

I'm using the following data frame: df1 <- structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 2L,2L,2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,1L, 2L, 2L, 2L, 2L, 2L,...
John Gagnon's user avatar
4 votes
1 answer
1k views

R ggplot 2 legend border issue

I know this is minor, but it's for a publication and will drive me crazy. The bottom of the P0688 box is like 1-2 pixels thinner than the rest. I don't want to make the borders thicker because then it ...
Paul Manley's user avatar
4 votes
0 answers
450 views

in R, creating multi column legend in ggplotly

How do you spread a legend over multiple columns in ggplotly? The answer here makes it obvious how to do so using ggplot() - however that code doesn't seem to work when I use ggplotly() library(...
val's user avatar
  • 1,689
3 votes
1 answer
689 views

R ggplot2 overlapping histogram, adding in legend for overlapping part

I have a histogram that is plotting 2 different groups with some overlap between them. I have been able to manually color the groups and a legend is generated for each group, however I am asking how ...
Cyph's user avatar
  • 81
3 votes
0 answers
465 views

Change title legend position using guides() without breaking the legend into discrete numbers

I was wondering if you can help me out with a (probably silly) problem with my code that is driving me nuts. I'm using R and my problems are with the package sf + ggplot2. Is there anyone out there ...
bmora's user avatar
  • 77
3 votes
0 answers
2k views

Theme(position.legend="none") doesn't work with coord_flip()

I want to have a horizontal bar chart, but without legend. When I run the script below without coord_flip(), no legend shows. But when I run it with the coord_flip() argument, the legend appaers. I ...
SHW's user avatar
  • 491
3 votes
1 answer
1k views

breaks and values not matching up in plot when using scale_color_manual in ggplot2

I am trying to graph multiple graphs using the same colors (values) for each group I am plotting using scale_color_manual. It seems to work well for many of the graphs, but not all and I cannot seem ...
Megan Ladds's user avatar
3 votes
0 answers
2k views

ggplot2: Stacked bar and legend on the top

I am trying to plot my data using stacked bar plot. I want to put the legend on the top of the plot for aesthetics reasons. However, when I do so the order of the does not match the order of the ...
degopwn's user avatar
  • 517
3 votes
0 answers
11k views

How to change legend labels in ggplot2 for visualizing data in R?

I am using ggplot2 to visualize some data in R. Therefore I use the following command: ggplot(second_sentiment_counts)+ aes(x = sentiment, y = n, fill = as.factor(sentiment)) + geom_bar(stat = "...
Lucinho91's user avatar
  • 195
3 votes
0 answers
193 views

legend changes unexpectedly with ggplot2

Any idea why this happens? Reversing the order of the legend changes it quite substantially. ggplot(mtcars, aes(x = disp, y = mpg, colour = disp, size = disp)) + geom_point() + ...
RobertMyles's user avatar
  • 2,803
3 votes
4 answers
2k views

ggplot has two legends and the wrong shape shows up in the color legend

I am creating a graph use ggplot in R but the legend is not showing up properly. First, I am getting two legends, one for color and one for linetype. These are both showing up despite the fact that I ...
carparminder's user avatar
3 votes
0 answers
7k views

ggplot different legends for different facets

I'd like to use different legends for 2 of the facets in this plot. The facets for 'Sharks' and 'Tunas' include multiple fish species, so I would like each facet to contain a unique legend for those ...
ament's user avatar
  • 83
3 votes
0 answers
1k views

Transform legend when using geom_point and geom_tile for discrete scales (ggplot2)

I am trying to plot trends in precipitation from different simulations. I have a data frame, called df, of this kind: Type season X Y Val 1 25 Ana Annual 76000 2393000 9.724501 2 ...
Chika's user avatar
  • 1,487
3 votes
0 answers
282 views

vertical oriented linetype legend

I am using the following guide style: guide.style <- guide_legend(keywidth=.1, keyheight=.5, direction = "horizontal", title.position = "top", ...
Joshua Pritikin's user avatar

15 30 50 per page
1
2 3 4 5
23