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

Questions tagged [legend]

A graph legend is commonly used when plotting several sets of data within the same diagram. The legend associates each plot with its corresponding data.

4 votes
1 answer
31k views

ggplot2: Reorder items in a legend [duplicate]

I have a stacked bar graph and I'd like to reorder the way the legend appears. I'd like the legend to show the order in "Social", "Economic", and "Environmental", but ...
0 votes
1 answer
25 views

Number of bins and labels do not match in matplotlib [duplicate]

I have a customize legend in my matplotlib but for some reason I cannot get the bins and the labels to match. If I add one more label, it starts to complaint that I have to many labels in comparison ...
1 vote
1 answer
43 views

How to change legend key shape for ggtree [closed]

I am working with a ggtree plot. Data used is available here and you can pull the phylo tree directly from ggtree. Load required packages #load libraries pacman::p_load( here, ...
14 votes
3 answers
8k views

Reverse order in R leaflet continuous legend

I am trying to reverse the value display of my leaflet legend in R. This post covers categorical data, but I am working with continuous data. Here's a toy example: map <- leaflet() %>% ...
29 votes
2 answers
31k views

how to align the legend title to the middle of legend box in ggplot2?

I want to move the legend title sex a little right to the horizontal center of legend box. I tried theme and guide_legend but failed. Both ways won't change the legend title position. # example data ...
0 votes
0 answers
11 views

Adding new chart series but excluding them from the legend

VBA. I'm trying to edit a chart by adding multiple new series to indicate when certain phases begin at certain times. I've done this by writing code that creates series using x values of the date i.e. ...
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 ...
1 vote
2 answers
50 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 ...
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
33 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
37 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 ...
1 vote
1 answer
30 views

Showing or saving only the legend of a plotly figure

Given a plotly figure with traces and a legend, is there a way to only show the legend without any of the plot content? My use case for this: I'm exporting several images with the same legend. Instead ...
0 votes
0 answers
25 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
29 views

How do I make one legend for all subplots in a sns.histplot without duplicate labels?

I have a dataframe that I'm plotting using sns.histplot to make ~9 subplots. I do not want the figure to have 9 legends. I'd like 1 legend for the entire figure, since most of the legends are ...
3 votes
3 answers
3k views

remove strikethrough behavior in chart.js bar chart

i am trying to change the look of the legends by removing the strikethrough effect , wihtout using legendCallback function in chart.js. The reason why i do not want to use the legendCallback function ...

15 30 50 per page
1
2 3 4 5
345