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

All Questions

0 votes
1 answer
78 views

Sharing multiple legend symbols within a ggplot2 scatterplot

I am trying to create a simple scatterplot in ggplot2 that has a unique shape for each factor level but certain colours are the same. I can achieve this, but would like a nicer looking legend where I ...
James White's user avatar
1 vote
1 answer
170 views

How do I seperate two overlapping legends for a dual axis ggplot, one legend representing variables by shape and another representing groups by color?

I have the following dataframe as a reprex: weather <- data.frame(time= c("12:19","12:15","13:20","13:22","16:19"), sensor_rh = c("A",&...
T.Becker's user avatar
0 votes
2 answers
771 views

How to add legend to scatter plot in ggplot?

I have assigned a shape and color to each point, and I want to draw the legend according to the group data, but I can't add the legend.. library(datasets) library(tidyverse) library(reshape2) name &...
RYENFLUSSH's user avatar
0 votes
1 answer
99 views

Duplicated legends in scatter plot

I'm plotting this ggplot2, but I can't get rid of the duplicated legends. I assume this is a very silly mistake of mine, any ideas? Plot: Code: data %>% ggplot(., aes(x = X, y = Y)) + ...
Larissa Cury's user avatar
0 votes
2 answers
208 views

Fixing legend in ggplot

I am plotting a scatter plot with 4 geom_ablines. The current plot looks like below: I want to make two changes in the legend of this plot. Removing the dot points on lines in the legend. Making the ...
Muhammad Usama Ashraf's user avatar
0 votes
2 answers
218 views

How to fix the legend for a grouped scatter plot added with geom_ablines

I want to make a scatter plot with two different groups (based on Size) each plotted with specified colors (Blue and Red). In addition, I want to add 4 geom_ablines to the scatter plot with the same ...
Muhammad Usama Ashraf's user avatar
1 vote
1 answer
340 views

Divide legend in two columns ggplot2

I have the following table: Sample UMAP1 UMAP2 colors tissue C_A1 1.41771557752425 1.22200433730937 yellow2 Urine C_A2 1.76055361418532 1.34108703383903 yellow2 Urine C_A3 ...
Emilio Mármol Sánchez's user avatar
0 votes
1 answer
962 views

Adding legend to ggplot + putting two scatter-plots onto one graph

I have been trying to add a legend and amend it, however after spending hours on different websites, books, etc. I was unable to do it. Data used to produce below graphs -> https://1drv.ms/u/s!...
Martin's user avatar
  • 13
0 votes
0 answers
2k views

Change legend labels ggscatter plot in r studio

I am trying to change the labels of the legend in my ggscatter plot. This is my code: plot=ggscatter(ALL, x = "CSdepth", y = "Cslength", add = "reg.line", ...
Lina's user avatar
  • 59
2 votes
2 answers
179 views

How do I get my legend dots blue and red instead that both are red?

I am trying to get a red and a blue dot in my legend, this is not the data that I am using but a reproducible example, The graph exits of two dataset, example is one of them and example1. here is my ...
Diego Martinez's user avatar
1 vote
1 answer
190 views

Why is my legend not appearing next to the graph?

I have two different datasets in one scatter plot, prediction2020_bounds needs to be blue in the legend and median2020 needs to be red in the legend. Here my code: ggplot() + # Points ...
Diego Martinez's user avatar
2 votes
1 answer
59 views

Indicate three diferent values in a scatterplott using colors

I have the following task from my professor: Use ggplot2 and create another scatterplot of the variablesact_sm and pop_sm. This time the actors from the US (3), UK (4), and the transnational actors (...
Nat Ba's user avatar
  • 23
1 vote
1 answer
239 views

Adding a point to ggplot legend from another dataframe

I am trying to add a reference point to my legend from another dataframe. Currently, my legend shows the values for my first geom_point() but I want to add a point in grey with the label "...
joy wyckoff's user avatar
0 votes
1 answer
373 views

Define and specify legend quantiles scatter plot R

I have eg data and syntax for a scatter (jitter) plot below eg_data <- data.frame( period = c(sample( c("1 + 2"), 1000, replace = TRUE)), max_sales = c(sample( c(1,2,3,4,5,6,7,8,9,10), 1000, ...
Adam_S's user avatar
  • 730
1 vote
0 answers
492 views

How to plot a legend for the color coded density scatter plot?

I am making a scatter plot with color coded density with this code : d1 = densCols(newData_cut, colramp = colorRampPalette(c("navy blue","yellow","firebrick","firebrick"), ...
NSS's user avatar
  • 11

15 30 50 per page