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,509
questions
0
votes
2
answers
22
views
Ggplot2: Create legend using scale_fill_manual() for geom_rect() and geom_line() in one plot?
I want to create a plot with geom_line() and geom_rect(). For both I would like to create a legend, but I does not work. How can both be combined? As you can see in the attached picture, my legend is ...
0
votes
0
answers
10
views
Placing a legend for multiple calls of ax.contour(x,y,data,label="2000") does not appear
I am trying to plot contour lines with labels as seen in the code below. What I want is that a legend appears on the lower right side with labels and colors same to what was set in ax.contour()
This ...
2
votes
0
answers
25
views
ggraph make filled arrow edges appear in legend
I'm trying to make a genealogy diagram of the history of EDA, coloring the edges and arrows by the Institution of the PhD degree. This sort of works, but the filled arrow heads in the diagram appear ...
0
votes
0
answers
9
views
Add branca.colormap.LinearColormap to an folium.FeatureGroup?
I have 1 folium.Map with 4 featuregroups, each folium.Featuregroup has an folium.Choropleth.
So I want to have linear scale for each featuregroup using the bins list that I've created, which include ...
0
votes
0
answers
16
views
R change legend order from alphabetical to numerical [duplicate]
How can I change the order of legend elements to the numerical values instead of the alphabetical in ggplot? So i want to go from 1,10,2,3 to 1,2,3,10.
I know that i can set the order by hand for each ...
0
votes
0
answers
7
views
fusioncharts how to hide several data series by clicking one legend item?
i am using fusioncharts (3.16) to draw several group lines in a chart (msspline). i set main/primary lines visible in legend and secondary lines are set invisible in legend. now i want to hide all ...
0
votes
1
answer
28
views
Change ggplot2 legend order without changing the manually specified aesthetics
I need to make a graph with multiple kinds of data on it, and I'm plotting one type of data with lines and one type with points. I've added a manually specified legend to show which type is points and ...
1
vote
1
answer
34
views
How to align a single legend over two seaborn barplots?
I would like to have a single legend that nicely fits on top of both the subplots (doesn't necessarily need to span the entire width of the plots, but needs to be outside the plot). I know you can ...
0
votes
1
answer
12
views
Lineplot - plot a single legend for uneven number of subplots
I'm working on the following graph where I'd like to plot is single legend that applies to all, essentially this would be a small box where blue color line is AB=0 and green line is AB = 1.
Moreover, ...
0
votes
1
answer
17
views
GGplot2 in combination with Guide_legend arguments
theme_pubr in the ggpubr package by default creates legends with the title on the side and the variables distributed horizontally. However,i'm trying to make a legend with the title on top and the ...
-1
votes
1
answer
33
views
How to add legend in overlapping histogram in python
I'm trying to add a color legend for the overlap. I don't have a plot for this because it's the overlap of x and y so I can't add legend from label like I did for x and y ...
i want to have a third ...
1
vote
1
answer
26
views
Placing a Legend Title Above a Horizontal Legend Already Positioned at the Top of a Barplot ggplot
Issue:
I have done a lot of research and tried many different solutions and I could not find an answer to my problem, at least not one that worked for me. I am attempting to place the legend title '...
0
votes
1
answer
9
views
Add linetype to geom_segment legend
Aim: add the linetypes of the segments to the legend, as well as the colour.
Problem: only the colour is showing.
Data:
m = as.data.frame(matrix(c(1:10), ncol = 2, nrow = 10))
Plot:
ggplot(m, aes(v1,...
0
votes
0
answers
21
views
Figure legend error: 'legend' is of length 0 - NMDS plot
I have constructed NMDS plots with data grouped by two variables (Dungfauna and Heating), however when I try to add a figure legend I get the error: 'legend' is of length 0.
There is another ...
0
votes
1
answer
24
views
Hide a specific legend only from FusionChart
How to hide a specific legend from multi-series fusionChart. Actually I want to remove a specific series from chart, when exporting I need to show that on excel sheet. So my plan is initial time hide ...
0
votes
1
answer
17
views
Legend position is not vertically in middle in Donut chart
In Donut chart Legend position is right but i want to add vertically in middle with corresponding of circle.
I am new to chartjs and JavaScript. Below is my code snippet. I am trying to load the pie/...
0
votes
0
answers
11
views
How to do Spaghetti plot in SAS with multiple legend?
I have the following data set
data sgplot_df;
input trt_group$ time subject$ results;
datalines;
TrtA 2 100 20
TrtA 4 100 30
TrtA 6 100 35
TrtA 8 100 50
TrtA 2 200 40
...
0
votes
1
answer
17
views
Can the grc1leg command combine the legend for multiple kdensity plots in Stata?
I am creating kdensity curves for income (kerr_income) distributions in a year (taxyear) by gender (male). However, when I create the kdensity plot, I cannot combine the legend to differentiate by ...
0
votes
0
answers
8
views
Overwrite lifetimes subplot labels
t = 120
from lifetimes import BetaGeoFitter, ModifiedBetaGeoFitter
mbgf = ModifiedBetaGeoFitter()
mbgf.fit(summary_cal_holdout["frequency_cal"], summary_cal_holdout["recency_cal"], ...
0
votes
0
answers
18
views
One Highcharts legend for two charts in React JS
I have two stacked column charts next to each other, sharing the same categories, and I would like them to both be controlled by the same legend. So that there is only one visible legend, but clicking ...
0
votes
2
answers
26
views
Adding a legend to a plot with two data frames using ggplot2 (r)
I'm trying to plot the median heart rate of boys & girls per minute in a PE lesson to see if there are some gender differences. I'd like to plot 2 line graphs using ggplot2 in two different ...
0
votes
2
answers
44
views
Handling events in interactive Vega legends - race condtion
The linked chart contains only a legend and the legend works as follows:
clicking on a fruit name toggles it on and off
shift-clicking on a fruit name switches it ON and switches OFF all other fruit ...
0
votes
1
answer
14
views
Reverse legend in geom_contour
I'm struggling to find the right solution to reverse the legend, so that red is at the bottom and greens at the top. Here's a simple example.
library(ggplot2)
library(dplyr)
x = seq(0.01,1,0.01)
y = ...
0
votes
1
answer
30
views
How to make alpha (transparency) appear as continuous gradient in the ggplot legend?
Is it possible to make the transparency (alpha) appear as a continuous gradient in the ggplot legend? Currently, the plot looks like this:
Here, the different values for alpha are represented by dots ...
0
votes
1
answer
20
views
Tried scale_linetype_manual to add legend but not successful
Following the thread from Tried p + scale_fill_discrete(name = "New Legend Title") but legend title still not changing, I now only want to generate line plot with legend based on the line ...
1
vote
0
answers
20
views
R: How to add fill color to a dot with legend with black circle outline
I am trying to create a legend (with empty plot) where each dot is associated with a group, but can't seem to figure out how to add fill color while having a black outline. It seems that my bg ...
0
votes
0
answers
13
views
Geoserver - Legend - Delete group text to keep only that of the element
I would like to delete the group or subgroup text in the caption to keep only that of the element next to the symbol.
How can I do this?
See screenshot.
enter image description here
0
votes
0
answers
13
views
Missing Labels from Legend With Subplots
I'm trying to plot multiple things in a figure with subplots.
When I try generating a legend for the figure, it is only showing labels for the data in the very last subplot, instead of for the entire ...
0
votes
1
answer
35
views
python : using a subplot as legend for the others subplots
I have the script below that generates a plot consisted of 5 histograms (5 subplots) :
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
from scipy.optimize import ...
0
votes
1
answer
23
views
Format of legend with equation in matplotlib
How do we show an equation in the legend of a pyplot plot?
Sample code below:
fig = plt.figure(figsize=(5, 3), dpi=my_dpi)
ax = fig.add_subplot(111)
a = 2.0
b = 3.0
xdata = np.arange(6)
ydata = a*np....
1
vote
1
answer
34
views
Forcing the legend in Vega chart to draw (and then using it for data filtering)
I have created a stacked bar chart where the dimension for the color of the stacked bars is selected from a drop down. (Can be Country, Fruit Name, etc.)
In the legend box I want to show colors ...
1
vote
2
answers
41
views
ggplot maps colours in wrong order
Creating a graph with several variables in ggplot, I map the colours using scale_colour_manual but the graph and legend applies the wrong colour to the wrong variable and the whole thing is mixed up. ...
1
vote
0
answers
31
views
Plotly graph legend groups feature is different when using fig.show() and Flask
I am developing a Flask application and a graph I am plotting with Plotly needs groups in the legend.
I followed this answer to achieve what I wanted. It works well when showing the graph with 'fig....
1
vote
2
answers
49
views
Why does the ggplot legend show both line colour and linetype?
I want the legend to show a blue solid line for "Panel regression", and a grey dashed line for "y = x". Why does it show the diagonal dashed lines in the legend?
ggplot(df_REM24, ...
0
votes
0
answers
12
views
adding a legend outside of barchart
I created a side by side barchart using this this code
IT=c(0.588, 0.765)
DE=c(0.214, 0.63)
FR=c(0.37, 0.73)
PL=c(0.692,0.793)
GB=c(0.381, 0.757)
NL=c(0.227, 0.62)
GR=c(0.692, 0.902)
HU=c(0.706, 0.698)...
0
votes
1
answer
23
views
Legend using leaflet
I create this code, it is work but when I add a legend it doesn't work well. Someone can help me? I need the legend has the same value of nycounties$dimension, also I need to reorder increase.
...
1
vote
1
answer
28
views
How to plot the legend title above a horizontal legend
# Create the dataset
Groups <- c('Treatment A','Treatment A','Treatment A','Treatment A',
'Treatment B', 'Treatment B', 'Treatment B','Treatment B',
'Treatment C', 'Treatment ...
0
votes
2
answers
41
views
How do I add a legend based to my scatterplot based on annotate("rect")?
I have created a scatterplot using ggplot2 in RStudio with the function annotate("rect".... to add a layer of colours based on another variable. I have been trying to add a legend for SO ...
-1
votes
0
answers
26
views
Removing one of legends in SNS relplot [duplicate]
The following is my code using seaborn to plot the relationship between child_mort and life_expec.
p=sns.relplot(data=df, x='child_mort', y='life_expec', hue='cluster', size='income', style='cluster', ...
0
votes
0
answers
20
views
Generating 6plots in 3rows and 2columns with same legend symbol and colors for same data value in Matlab
I have x, y and t variables for the above function. t contains a 16 different names distributed among the 6 sections. I want to plot the six plots in a nexttile or subplot format such that the same ...
0
votes
1
answer
31
views
Add a legend for a geom_text layer to explain labels
Consider the following example where a scatter is made and only the "significant" point are colored and labelled.
genes <- read.table("https://gist.githubusercontent.com/...
0
votes
1
answer
33
views
ggplot2 scale_color_identity() how to change linestyle and design of the legend?
I coded the following ggplot. The problem is that the design of the legend is flawed: The elements of the legend are interconnected with what appears to be dashed lines. How can this be removed? And ...
1
vote
2
answers
32
views
Add legend to Dash DataTable
Starting from the following code, I'd like to add a legend to this tabular:
from dash import Dash, dash_table
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/...
1
vote
2
answers
32
views
Gnuplot legend with two boxes/groups and custom heading
I have two types of data/plot and I want to group them for clarification. For example, lets say I have this four data plots
set key box
pl x, x**2, sin(x), cos(x)
And the legend box comes out to be ...
0
votes
0
answers
10
views
QGIS doesn't make the correct legend with using color_rgb even though the colors in the polygons are correct
I'm working on my QGIS portfolio and doing some training with public geologic data. I used to use MapInfo and would use RGB fields, tie them to the polygons, and make the correct geologic colors. I'm ...
1
vote
1
answer
35
views
R plot changing Legend's Line's pch color
I have my graph here,
plot(c(1:10),type = "l")
lines(c(1:10), type = "p", pch = 20,lwd = 4, col ="#4169E1" )
abline(h = 5,lwd = 2 , col = "#7f41e1")
abline(h = ...
0
votes
0
answers
54
views
How do I stop a ggplot graph legend from getting cut off on the right when exporting-saving when using showtext?
Just started R a couple weeks ago. Getting familiar with ggplot. I successfully made the graph I wanted to including all legends, axes titles, etc. I'm able to export/save this image fine. However, ...
0
votes
0
answers
8
views
legend outide axes - bbox_to_anchor not alligned with other axes
I'm trying to plot multiple subplots with a custom layout with GridSpec.
Some of these axes share the same data so I would like to plot a single legend that is enclosed inside the "grid space ...
0
votes
0
answers
15
views
Matplotlib legend - how to put multiple handles with the same key vertically below each other?
What is the easiest way to place multiple legend handles belonging to the same key vertically below each other (analogously to the HandlerTuple placing them horizontally next to each other)? Can this ...
0
votes
0
answers
23
views
Modify legend name in boxplot ggplot2 [duplicate]
I have this boxplot but I would like to change the legend for the actual name: 1 = "Pfizer-BioNTech", 2 = "Moderna", 3 = "Oxford-AstraZeneca". This variable is coded as a ...