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.
legend
5,167
questions
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 ...
1
vote
1
answer
40
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 ...
0
votes
1
answer
31
views
Is it possible to count the occurrence number of a custom icon in Leaflet? If yes, how to do it?
Firstly, I'm a beginner, I've learned a lot from you.
I have 5 custom icons defined:
//Awesome icons
var LeafIcon = L.Icon.extend({
options: {
shadowUrl: "markers-shadow.png",
...
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
2
answers
43
views
Altair chart legend for subset of data
As an exercise for learning more advanced altair, I'm trying to generate a simplified version of this chart: https://climatereanalyzer.org/clim/t2_daily/?dm_id=world.
To simplify, I'm using gray for ...
0
votes
1
answer
28
views
Plant UML Multiple legend in Gantt View
How to add Multiple legend with different colors in Gantt Chart using Plant UML?
It's working for me, for one legned. It's taking the last line of code...
Is there a way to show, different parameter ...
519
votes
9
answers
1.0m
views
How to change legend fontsize with matplotlib.pyplot
Simple question here: I'm trying to get the size of my legend using matplotlib.pyplot to be smaller (i.e., the text to be smaller). The code I'm using goes something like this:
plot.figure()
plot....
222
votes
11
answers
452k
views
Plot a legend outside of the plotting area in base graphics?
As the title says: How can I plot a legend outside the plotting area when using base graphics?
I thought about fiddling around with layout and produce an empty plot to only contain the legend, but I ...
7
votes
1
answer
4k
views
Replace Matplotlib legend's labels with image
I would like to use image instead of labels in the legend.
For example, I draw 2 lines and show a legend :
import matplotlib.pyplot as plt
plt.plot([1,2],label="first_image")
plt.plot([2,1],label="...
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 ...
1
vote
0
answers
39
views
Text shifted in legend because of LaTeX formatting in matplotlib
For some reason in my subplot, the legend of the second ax is cropped at the bottom inside of the legend box. It seems the index causes the text to shift a bit.
The legend box itself is perfectly fine....
0
votes
1
answer
66
views
Add size legend to plotly.express.scatter_mapbox
I have a visualization done using plotly.express.scatter_mapbox. It basically shows the different institutions on the Saudi Arabia map. These institutions are marked by small circles that are color ...
1
vote
0
answers
35
views
How to add a FancyBbox as a legend?
As per the title, I'm trying to add a list of fancy bboxes to a legend : https://matplotlib.org/stable/gallery/shapes_and_collections/fancybox_demo.html.
I tried the code below but there is a problem. ...
0
votes
1
answer
42
views
How to make responsive 'legend' area for mobile view
I'm building a portfolio website using HTML & CSS. I want to add my projects inside tags. But those legend tags arn't responsive for the screen resolution(for me, it's mobile view) and its' ...
118
votes
6
answers
126k
views
Show only certain items in legend
I currently am plotting a stacked bar graph of a large amount of taxonomic data, and only wish to show significant species in the legend (out of ~500 I wish to show ~25). Is there a simple way to do ...
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
23
views
How to keep decimal places in branca colormap using folium?
I'm using branca to create a custom color map to use in a folium map. I would like for the scale to display the decimal places from the index still, not round to a whole numbers, but I'm having a hard ...
0
votes
0
answers
38
views
Putting Legend completely outside the plot in right center
I am trying to create a plot where the legend will be in the right center but completely outside the plot. I am following this answer https://stackoverflow.com/a/75453792/3587282 and using Matplotlib ...
0
votes
0
answers
21
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 ...
5
votes
1
answer
365
views
Legend obscures plot using Seaborn Objects API
I have a recurring problem with legends on many of my plots with legends. The legend often obscures part of the data.
Reproducible example:
import seaborn.objects as so
import numpy as np
import ...
2
votes
1
answer
247
views
Is there an alternate for 'palette' while plotting barplot through seaborn object Plot(); How to remove legend when plotting with so.Plot()
I am trying to learn the seaborn object Plot() interface. With the traditional sns.barplot() we could easily define color palette for the bars.
import seaborn as sns
df = sns.load_dataset('penguins')
...
3
votes
2
answers
163
views
How to reposition Figure legends into subfigures
I am new to this, trying to plot 2 subfigures horizontal with sample data using Matplotlib and Seaborn library in Jupyter Notebook, the 2 sub-charts come out alright, but the 2 legends overlap each ...
7
votes
2
answers
2k
views
How can I customize the legend with Seaborn 0.12 objects?
The new Seaborn objects (v 0.12) are great but I struggle to deal with legend customization. Especially when using matplotlib to define subplots. My code:
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, ...
1
vote
1
answer
6k
views
WPF Chart Legend Item Style
I am trying to style the Legend Items in my WPF Chart. I have the following LegendStyle, but this doesn't change anything. What am I doing wrong?
Thanks!
<Style x:Key="LegendStyle1" TargetType="{...
20
votes
2
answers
26k
views
One shared legend for a cowplot grid in R
I just built a grid with package cowplot (to label the plots from A-D). The plots are made with package ggplot2:
pfour<-ggplot(four, aes(x=Concentration, y=Percentage, fill=Phenotype)) +
...
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, ...
94
votes
9
answers
48k
views
Making a Legend/Key in GraphViz
I’d like to include a legend or key in my GraphViz diagram. I’m having trouble figuring out what code to use, though. I also want to put it in a corner, but the only coord I know for sure is the ...
0
votes
0
answers
37
views
Dynamic positioning of checkboxes next to chart legend in Plotly Dash
I am currently creating a dashboard with Plotly Dash in Python and have a layout problem that I just couldn't fix over the last couple days:
I have a bar chart with a metric, that is always shown and ...
10
votes
2
answers
19k
views
Plotly: How to set up multiple subplots with grouped legends?
for each subplot I have 3 seperate line:2017 ,2018 and 2019 with 3 times "go.Scatter", each subplot represents one country (25 countries) with always these 3 years. I can use the subplot ...
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
30
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],...
116
votes
10
answers
164k
views
Plot labels at ends of lines
I have the following data (temp.dat see end note for full data)
Year State Capex
1 2003 VIC 5.356415
2 2004 VIC 5.765232
3 2005 VIC 5.247276
4 2006 VIC 5.579882
5 2007 VIC ...
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 ...