All Questions
2,486
questions
1
vote
1
answer
37
views
How to change legend key shape for ggtree [closed]
I am working with a ggtree plot. The data used is available here.
Load required packages
#load libraries
pacman::p_load(
here,
dplyr,
googlesheets4,
...
1
vote
2
answers
48
views
Add a legend to a voronoi diagram with field values
I try to create a map with a voronoi diagram of some climate stations. I've already created the diagram and also colored the areas in the diagram with a fitting color. Now I want a continuous legend ...
1
vote
2
answers
56
views
function for geom_point to increase the scale_size
LATER EDIT: I finally figured out how to do it. It works with the following code:
legend_size <- c(6,5,4,3,2,1,0,1,2,3,4,5,6)
tt <- data.frame(x = c(27.9656, 27.1704, 26.2128 ,23.5634 ,25.3528 ...
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
0
answers
29
views
How to plot the legend with combined_plot (ggplot2)
I created this script to display some environmental impacts for my research.
`legend_plot <- ggplot(data_longGW, aes(x = Crop_cycleGW, y = kg_CO2_eq, fill = Category)) +
geom_bar(stat = "...
1
vote
1
answer
35
views
Legend key color when combining ggOceanMaps and ggspatial
I am trying to combine basemap from ggOceanMaps with geom_spatial_point and having the geom_spatial_point having a new color scale.
When I combine these two, the legend.key background color remains ...
0
votes
0
answers
24
views
How to color the legend labels in ggplot [duplicate]
Using the iris dataset, we can make a boxplot and customise the legend when plotting using ggplot like so:
ggplot(data = iris, aes(x=Species, y=Sepal.Length, fill=Species))+
geom_boxplot()+
...
1
vote
1
answer
38
views
ggplot of multiple geom_sf datasets gives mismatched legend colours
I am trying to create a ggplot map which includes two simple feature line datasets. I would like the lines to either appear in the same legend, or a separate legend. However the approach I am taking ...
1
vote
2
answers
51
views
adjusting the legend in TramineR plots
I am new to using TramineR and I just cannot seem to figure out how to arrange the legend in any of the plot types. The legend keeps being cut off by the plots. I have tried to use the seqlegend ...
0
votes
0
answers
28
views
Having problem adding legend onto my ggplot when ggplot's data argument is NULL [duplicate]
New to r here, so please bear with me. I am sure this is something simple to solve. I have this plot here and want to add a legend to distinguish which line represents the "Tailwater Gauge" ...
2
votes
1
answer
35
views
Rotating/angle of ggplot key_glpyh, custom legend key glyph
I am trying to emulate a plot style ive seen online, created by Chris Canipe (https://www.axios.com/2017/12/15/the-flow-of-goods-between-states-1513304375). Looking at trade flows, I've managed to ...
1
vote
1
answer
27
views
R Customize ggVennDigram legend based on internally defined categories of mapped colors - not counts nor individual intersections
First time posting here...
I have a Venn diagram where I have coded certain regions of intersections based on internally defined categories. I want to produce a legend that reflects those categories.
...
0
votes
1
answer
38
views
Trying to remove the background of color icon in ggplot legend
I'm trying to remove the gray box behind the color icon in the legend of this graph. Wondering if the issue is that I'm using geom_col() so the color aesthetic is just the outline of the column. Does ...
0
votes
1
answer
49
views
Reorder legend levels in CalendR
Using CalendR to plot fishing days for boats. How do you go about reordering legend levels e.g. boat names first then public holidays last?
Load packages, create events & plot calander:
## load ...
0
votes
0
answers
20
views
Increase spacing in ggplot legend items [duplicate]
I have two shapefiles of a Country, one containing the geometry of the municipalities and the other regarding the border of the regions of the country. I have to plot the country with the ...
0
votes
1
answer
43
views
Edit legend title in ggplot2 (3.5.1) [duplicate]
I have successfully edited the x and y axis titles, but I'm stuck on the legend title and labels.
Here is the code I have run so far:
m.emo.plot <- interact_plot(model = m.emo, pred = cemodiff, ...
0
votes
1
answer
27
views
How to avoid overlapping legends for multiple geom_point layers in ggplot2
I'm trying to create a chart with 2 geom_points and a geom_text_repel layer. When I display my legend, the geom_points overlap. The main data points should be represented as empty circles, while the &...
1
vote
1
answer
29
views
How to Add a Legend to a ggplot with two axes
I've put together this graph and I would like to be able to add a legend to it but can't seem to figure out why it's not showing up and how to easily add it.
data <- data.frame(group = LETTERS[1:5],...
0
votes
1
answer
19
views
Centering a `ggplot2` Plot Legend in a Blank Plot
I have the following graph.
ggplot() +
geom_hline(aes(yintercept = 0, linetype = "Line 1"), color = "white", size = 1.25) +
geom_hline(aes(yintercept = 0, linetype = "Line ...
0
votes
1
answer
35
views
Changing the Legend Title in a `ggpointdensity` Density Scatterplot [duplicate]
I have the following data and the following graph.
df <- data.frame(col1 = rnorm(1000, 0, 0.05), col2 = rnorm(1000, 0, 0.05))
ggplot(data = df, mapping = aes(x = col1, y = col2)) +
...
0
votes
1
answer
65
views
Add legend after using gg.gap
I have a data set with a big negative value, so I used gg.gap package to make a discontinuous y-axis. The code worked well but after adding the function gg.gap the legend was deleted.
I tried adding a ...
2
votes
1
answer
44
views
How can I make the legend appear on this chart?
I've drawn this quartile for the runoff rate, and I'd like the legend to appear as: - Median and - Q25-Q75. Can you please help me?
Runoff <- data.frame(Year = rep(1991:2002, each = 12),
...
0
votes
1
answer
38
views
I want to get two legends for two different groups in a two Y-Axis plot [closed]
so I have a two Y-Axis plot. Each Y-Axis is given a group of Data.
I want to have two different legends for each group on left and right side of plot on the locations shown in the second picture.
This ...
0
votes
0
answers
20
views
Change Orientation and Order of Items in Legend ggplot2 r [duplicate]
Is there a way to change the orientation of the items in the legend of ggplot2 chart?
I have a series of boxplots where I would like the individual items to oriented vertically opposed to horizontally....
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
3
answers
39
views
Legend is not shown using ggplot2 despite using color within aes()
I have a problem making the plot legend to show. I've checked other posts and most of them mention that color should be defined within the aes() of the ggplot.
So I have the following dataset:
date ...
1
vote
0
answers
30
views
Why is the coding for legend on my barplot not working after update?
I updated Rstudio and suddenly none of my legends are working on my barplots. It's my first time asking for help on here, so hopefully I am providing the info needed to get answers? Coding is below. ...
0
votes
1
answer
63
views
How to center legend text in ggplot
I have a plot that looks like this:
I used these data and code to produce it:
structure(list(zone = c("Zone 1", "Zone 2", "Zone 3", "Zone 4",
"Zone 5&...
2
votes
2
answers
168
views
Specify which legend to keep in wrap_plots
I'm looking to combine multiple graphs generated from different functions into a single display. Specifically, I want to only keep the legend of the first graph in the wrap.
Here is a minimal version ...
0
votes
1
answer
45
views
Legend is not reflecting symbol plotted in ggplot2
I have a dataframe that looks like this:
structure(list(season = c("Fall", "Spring", "Summer", "Winter"
), effort = c(2559.85453311966, 4741.60449074074, 2014....