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,162
questions
0
votes
0
answers
18
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
34
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
24
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
23
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
26
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 ...
1
vote
1
answer
37
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
votes
1
answer
44
views
Why is scale_fill_manual() adding a second legend to my linegraph? [closed]
I am trying to create a linegraph showing population change over time for two species. I managed to create the graph how I want it to be and am now trying to alter the aesthestics for a public poster. ...
0
votes
1
answer
25
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
46
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
34
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 ...
0
votes
1
answer
20
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 ...
1
vote
2
answers
42
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 ...
1
vote
1
answer
26
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.
...
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
37
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
42
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
33
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
40
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' ...
0
votes
0
answers
19
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
1
answer
48
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
37
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
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
39
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
0
answers
26
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 ...
0
votes
1
answer
26
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
32
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
48
views
Seaborn catplot legend's background color and border
MWE
from matplotlib import pyplot as plt
import seaborn as sb
df = sb.load_dataset("titanic")
g = sb.catplot(
data=df, x="who", y="survived", hue="class",
...
0
votes
1
answer
57
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
43
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
0
answers
8
views
Adapting the leaflet.js Choropleth example with non static legend
I am trying to use the beautiful base example Choropleth, but would like to have a second base map, with a second legend that would be linked to the base map used (therefore not anymore static), with ...
-1
votes
1
answer
41
views
Plot X and Y chart with third column as legend for each point in Excel or Google Sheets [duplicate]
I am having difficulty understanding why it is so difficult to do something so simple in R or Python in Excel or Google Sheets.
I want to plot Status1 versus Status2 in a simple X and Y plot. However, ...
0
votes
2
answers
34
views
2 legends on graph matplotlib [duplicate]
I want to plot a number of curves for different models. I have curves for different structures. The structures need to have the same color and the different models a different linestyle. I then want 2 ...
0
votes
0
answers
30
views
Plotting problems in python script vs jupyter notebook
I am encountering issues with my plotting code when running it as a Python script in PyCharm. The plots overlap, and the legends are not displayed, which does not happen when I run the same code in a ...
0
votes
1
answer
40
views
Why the legend merged with the d3.js line chart when zooming?
I am trying to add a legend to the d3.js example named
Line chart with zoom in d3.js
1°) I added the script:
// Add legend rectangle
line.append('rect')
.attr('x', width - 80)
....
0
votes
1
answer
37
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
18
views
Tableau: Can I have a button that the user can press to choose the color palette of a visual (map)
I am fairly new to Tableau.
I have a map. I wonder if I can have a button or something that a user can interact to change the colour palette of the legend.
This is useful for example, for color-blind ...
0
votes
1
answer
28
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
0
answers
13
views
When converting a ggplot() using ggplotly(), the legend is distorted. How can I prevent this
Here's the plot as generated by ggplot()
And here it is as mashed by ggplotly()
How can I fix the second plot to look like the first with respect to the legend? Please ignore the differences in the ...
0
votes
0
answers
46
views
Sorting rows of a matrix by column values in Power BI
I've created a matrix in Power BI similar to the one below. The entries are a calculated field. I can sort the rows by the "Total" column and the "Name" column by clicking on the ...
0
votes
3
answers
37
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
1
answer
16
views
Order of items in an R graph legend are different depending on different datasets of the same data
Newish to R and Stack Overflow but I wrote some R code to make grouped boxplots for chlorophyll data by season and site while including a water quality criteria reference line. It may not be the most ...
0
votes
1
answer
39
views
How to prevent hiding plotly chart bar on chart legend click
How to prevent hiding plotly chart bar on chart legend click in an angular application.
<plotly-plot
[divId]="graph.selectedGraph.name"
[data]="graph.selectedGraph....
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
148
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
43
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....