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

All Questions

Tagged with
0 votes
0 answers
11 views

How to merge shape and line color titles into one and edit legend in ggplot2

I am trying to make a ggplot graph with combined shape and color legends but also be able to edit the legend labels. I have the following code used to make a graph: Year.Avocet <- (1940:1980) N....
blake.struthers's user avatar
0 votes
2 answers
99 views

R ggplot: size of bins and labels in legend of binned variable

I want the legend of a binned variable discrete_var in the bottom of my figure. I want the bins on one row. The problem is that doing this results in different sizes of bins and the labels too close ...
MoonS's user avatar
  • 175
1 vote
3 answers
247 views

Add label between colorbar breaks in ggplot2

I am trying to create a figure with ggplot and would like to add category names between colorbar breaks (values). I am using a graduated colorbar using the scale_color_fermenter function, which I ...
Mohamed Ismaiel Ahmed's user avatar
0 votes
0 answers
67 views

Over ride the labs function for second legend title

plot <- ggplot(data2, mapping = aes(x=Long, y=Lat) ) + stat_density_2d(aes(fill = ..level..), geom = "polygon", colour="white") + labs(color = "Levels of ...
Arron_2012's user avatar
0 votes
2 answers
450 views

Ggplot2 legend with actual values instead of log

I created a map using ggplot2 where I show the trade balance of European countries vis-a-vis the rest of the world, using the code below: library(ggplot2) library(sf) library(giscoR) data <- read....
Saïd Maanan's user avatar
1 vote
1 answer
89 views

How to show the tags of an array of ggplots made with the patchwork package?

I have 5 plots that I want to organize in 2 columns: the first with 2 plots and the second with 3 plots. I used the patchwork package and the arrangement was the way I want it, but the tags don't ...
Daniel Valencia C.'s user avatar
0 votes
1 answer
1k views

R - Adding legend to ggplot graph for regression lines

I do a Multiple Linear Regression in R, where I want to add a simple legend to a graph (ggplot). The legend should show the points and fitted lines with their corresponding colors. So far it works ...
Wurschti's user avatar
1 vote
1 answer
350 views

Get cartesian coordinates for plot area ggplot2

I would like to position labels close to the legend. In the code below I have hardcoded (x,y) values in geom_label to get desired result for the current dataframe: # Creating dataframe library(...
Iraleksa's user avatar
  • 155
0 votes
1 answer
136 views

R ggplot Legend having unexpected output

I'm working on a R plot of some COVID data, plotting cases over time in China vs. cumulative cases in other countries. I am also adding some vertical lines marking some events. I am having a lot of ...
pikovayadama's user avatar
0 votes
2 answers
255 views

Fail to change the legend title and label with ggplot2 in R

I was trying to change the legend title from group to the Greek letter "sigma" and the label "power.1, power.2, power.3" to "35, 40, 45" but it did not appear and still ...
Fox_Summer's user avatar
0 votes
0 answers
264 views

ggplot2 bar chart rename legend labels with ggplotly()

I have a bar chart with states on x-axis, counts on y-axis and fill with 3 different years (2020, 2019, 2018). I want to rename the fill legend labels to following: This Year, Last Year, 2 Years Ago. ...
Peter Chen's user avatar
  • 1,474
0 votes
2 answers
2k views

How to change the label text in r?

I am learning r and I have problems with setting the label text(desired text) and adjust the size and bold fond for the legend title. I tried to find some help from other sources in stackoverflow and ...
Ben10's user avatar
  • 287
2 votes
1 answer
63 views

cannot modify legend attributes in ggplot2

I am trying to modify the color, labels and breaks on the legend of this plot, but the scale_xxx_yyyy options won't work. Any suggestions? My input is like this: GENE CHR POS key ...
Victoria Fernandez's user avatar
1 vote
0 answers
95 views

How to add label for each multiple plot?

p = ggplot() + geom_line(data = Month_time, aes(x = Month, y = CarrierDelay), color = "red") + geom_line(data = Month_time, aes(x = Month, y = WeatherDelay), color = "purple") ...
loms's user avatar
  • 11
2 votes
2 answers
246 views

How to understand which legend is which and remove one of them in ggplot in R?

I have read many questions here and in google about legends in ggplot. However, I still can not understand why the following code produces 2 different legends and how to control them seperately. ...
Ozgur Polat's user avatar

15 30 50 per page