Skip to main content

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.

1,295 questions with no upvoted or accepted answers
6 votes
0 answers
1k views

How to get leading whitespace in matplotlib labels (legend or xlabel etc.) using latex?

I would like to insert some leading whitespace into some of my legend labels (problem is the same for other types of labels) with latex turned on. However, any leading whitespace that I enter is being ...
Zaus's user avatar
  • 1,301
6 votes
1 answer
2k views

How to change cursor on plotly graph when mouse hover event occurred?

i'm trying to change cursor from pointer to default when hover event occurred on plotly's graph legend legend: { cursor: "default", x: xLegenda, y: yLegenda, ...
Giuseppe Giubaldo's user avatar
6 votes
0 answers
3k views

Using annotate to place a text box below legend in Matplotlib

I wish to display some text in a Matplotlib plot using annotate(), aligned beneath a legend box. I have examined the solution proposed in How to place a text box directly below legend in matplotlib? ...
Delory's user avatar
  • 71
6 votes
0 answers
11k views

Highcharts legend styling with usehtml

I need to use the pagination of Highcharts (v2.3.5) legend, as my graph use numerous series of data. The thing is I would like to add an image (with a dedicated tooltip) on each legend item, and so ...
user2047243's user avatar
5 votes
0 answers
165 views

How to have a legend for colored edges in Julia plots?

Here is a minimal working code from Julia Discourse: using LightGraphs using GraphPlot using Colors g = graphfamous("karate") membership = [1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,1,2,1,2,1,...
JKHA's user avatar
  • 1,876
5 votes
0 answers
281 views

Bokeh: How to hide legends for lines that belong to the same group/category

The scenario is the following: I have a set of data with 2 attributes: year and (export/import) There are 3 choices for years and 2 choices for (export/import) , counting in total 3*2=6 datasets. 1. ...
John's user avatar
  • 388
5 votes
0 answers
4k views

How to remove legend in the default r plot() function

I have a simple R plot (i.e. plot(object)) and would like to suppress the legend. I am not, and cannot, use ggplot - how do I prevent R adding a legend to the plot?
user265883's user avatar
5 votes
0 answers
775 views

How to fit a big legend under a chart?

I have a lot of elements in my graph, which don't fit into one line under the graph. How can I achieve a line break so that all legend's fit under the graph? Here is an example of my use case, copy ...
SiGa's user avatar
  • 187
5 votes
0 answers
488 views

Why legend box size increases when I zoom plot in r?

When I use legend command in r, the size of the legend box is true, but when I zoom plot, the size of the legend box increases with a large scale. Are there any options to set height and width of ...
mohammad's user avatar
  • 175
5 votes
0 answers
348 views

Legend is displaying additional shape

I'm using the following data frame: df1 <- structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 2L,2L,2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,1L, 2L, 2L, 2L, 2L, 2L,...
John Gagnon's user avatar
5 votes
1 answer
5k views

Place MATLAB legend such that it does not overlap on the plot

I am generating multiple plots of different datasets in succession using MATLAB. I would like the legend positions to be such that they don't overlap on the plotted lines and it would be ideal if this ...
Slothworks's user avatar
  • 1,083
5 votes
1 answer
3k views

Highcharts: are multiple legends possible?

I'm new to Highcharts and it seems excellent this far. However, I need to have my six series grouped into three columns in the legend. This can be achieved by limiting legend width and using ...
StackExchange saddens dancek's user avatar
5 votes
1 answer
1k views

How to make a Legend of MatPlotLib patch patterns or add them to a preexisting Legend

How does one make a legend for patch patterns used on a graph or add information on the patch patterns to a preexisting legend without affecting information already present on the legend?
Elliot's user avatar
  • 5,411
4 votes
0 answers
831 views

How to change legend text formatting in Leaflet in R?

I've created a leaflet map and I'm trying to figure out how I can change the formatting of the legend labels. I currently have a gradient color palette to represent the data, with a set of discrete ...
nkt95's user avatar
  • 65
4 votes
0 answers
418 views

R leaflet map - combine layer group selection with the legend?

I know there are several R leaflet threads on here about showing the legend of layers only when those layers are selected using the addLayersControl command. But my questions is slightly different a ...
tfarrugia's user avatar
4 votes
0 answers
573 views

How to manually scale a continuous legend in a seaborn scatterplot?

I'm creating a scatterplot with seaborn like this: plt.figure(figsize=(20,5)) ax = sns.scatterplot(x=x, y=y, hue=errors, s=errors*20, alpha=0.8, edgecolors='w')...
Chris's user avatar
  • 1,306
4 votes
1 answer
327 views

How can I make a cyclic, donut-like color legend in ggplot?

CONTEXT I have some data that looks like this: val = 0:100 sample_data = data.frame( t=val, px=cos(2*pi*val/100), py=sin(2*pi*val/100), v_angle = (val*360/100 + 90) %% 360 ) I am ...
Max Candocia's user avatar
  • 4,407
4 votes
1 answer
1k views

R ggplot 2 legend border issue

I know this is minor, but it's for a publication and will drive me crazy. The bottom of the P0688 box is like 1-2 pixels thinner than the rest. I don't want to make the borders thicker because then it ...
Paul Manley's user avatar
4 votes
0 answers
3k views

how to give custom design (icons) for point Style of chart js legends?

I have a chart which designed based on a mock-up but the the mock-up chart has used custom icons for legends pointStyles which basically i couldn't find them in chart JS itself, i tried different ...
Sajad Haibat's user avatar
4 votes
0 answers
3k views

matplotlib: multiple legends in each single subplot

I know how to split the legend of a plot into two separate legends: x = np.linspace(0,1) y1 = x y2 = 2*x fig, ax = plt.subplots() fig.set_size_inches((8,8)) points = [] pnts = ax.scatter(x, y1, c='...
GRquanti's user avatar
  • 534
4 votes
1 answer
1k views

How to reduce white space in octave legend function

I have build some algorithm and now I should make things pretty enough for presentation. Only problem what I have is a "strange" legend behaviour in octave. I dont know if the problem is because I am ...
Pukaai's user avatar
  • 377
4 votes
0 answers
2k views

Safari 11 Bug Fieldset-Legend with Overflow Hidden and Click

Since Safari 11 for Mac checkboxes (and links/other click-events) are inaccessible when placed in a <legend>, does anyone know of a workaround? JS fiddle contains a demo, neither the checkbox ...
elveti's user avatar
  • 2,356
4 votes
0 answers
450 views

in R, creating multi column legend in ggplotly

How do you spread a legend over multiple columns in ggplotly? The answer here makes it obvious how to do so using ggplot() - however that code doesn't seem to work when I use ggplotly() library(...
val's user avatar
  • 1,689
4 votes
1 answer
945 views

JVectorMap: update legend

I'm using JVectorMap to show a map with colored countries. The map also includes a legend and an onRegionTipShow. In my application it's possible to alter the values the map is based on. After doing ...
Newton's user avatar
  • 53
4 votes
0 answers
7k views

r-legend in stacked bar plot

I'm relatively new to R and struggling to get my legend in the correct place. I've had a good look online and just can't seem to figure it out. # rating no yes # 1 140 38 # 2 72 46 # ...
N Gross's user avatar
  • 41
4 votes
0 answers
2k views

Plot legend problems using R. Help removing excessive white space in legend box

I am creating a plot of some hydrology data and I am having trouble with the legend. The legend has a large amount of blank space around the text. I have tried using par(mar= list), cex, x.intersp, ...
blinid's user avatar
  • 41
4 votes
0 answers
3k views

How to properly propagate multiplex signal names to scope legend via bus system? (Simulink)

I substituted my originial question, the problem is still the same, but the conditions are now different. To review the original question, have a look at the revisions. I'm looking for a way to ...
Robert Seifert's user avatar
3 votes
0 answers
97 views

In a quiver plot with ShowArrowHead = 'off', how do I keep the arrowhead from displaying in the legend as well?

When plotting with quiver() and setting the 'ShowArrowHead' property to 'off', the arrowheads aren't shown in the plot (as expected). However, the legend entry still shows an arrowhead. I would expect ...
localhost's user avatar
3 votes
0 answers
62 views

Plot a boolean/qualitative table with R

I am looking for a way to create a table in R for categorical data. The elements in the table should be symbols, and these symbols should be displayed in a legend. This table from the ICILS 2018 ...
saykodelikat's user avatar
3 votes
0 answers
249 views

Plotly legend marker opacity and spacing

Is it possible to access the symbols in a legend? I would like to set their opacity to a higher value than the opacity of my trace markers, and ideally I would like to make them tighter (in the sense ...
Tim Kirkwood's user avatar
3 votes
1 answer
689 views

R ggplot2 overlapping histogram, adding in legend for overlapping part

I have a histogram that is plotting 2 different groups with some overlap between them. I have been able to manually color the groups and a legend is generated for each group, however I am asking how ...
Cyph's user avatar
  • 81
3 votes
0 answers
331 views

How to get R Plotly pie charts to show legends based on values other than labels

I am plotting a pie chart with R plotly which I want to slice the pie based on column A and color each slice based on column B. I want each slice to show label based on column A, and I want the ...
Bernard's user avatar
  • 73
3 votes
0 answers
180 views

How do I change de size of the legend with matplotlib? and identify the states on my map

I have made this code for an activity, I am a beginner in python. But when I plot, the legend only shows the first letter of my legend. Also, this map shows a group of states and I would like to know ...
Daniele Ingredy's user avatar
3 votes
0 answers
152 views

Create a legend for user-defined marker_colors in Plotly

I´ve set manually colors for some bars of a bar plot (one which corresponds to the max value and another one - to the value I´d like to draw attention to). Here´s a sample of the df ranking = df['...
Ksenia Kustanovich's user avatar
3 votes
0 answers
464 views

Change title legend position using guides() without breaking the legend into discrete numbers

I was wondering if you can help me out with a (probably silly) problem with my code that is driving me nuts. I'm using R and my problems are with the package sf + ggplot2. Is there anyone out there ...
bmora's user avatar
  • 77
3 votes
0 answers
286 views

Seaborn scatterplot shows wrong value in legend despite setting a max value in hue_norm

I want to have the seaborn scatterplot legend show different colours from 0 to 130, but instead it shows 50, 100 and 150. The max value in my dataset is 130, so it is very confusing to the reader to ...
nielsen's user avatar
  • 383
3 votes
0 answers
980 views

Colorbar too big - Python Matplotlib

I want to plot a geodataframe from Buenos Aires, the proportion of poor houses. There's the code: import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt caba=gpd.read_file('https:...
Tomás's user avatar
  • 31
3 votes
0 answers
256 views

Victory Chart Custom Legend in react

I want to change icon like but in documentation can't find custom legend
Armen Asaduryan's user avatar
3 votes
0 answers
2k views

Theme(position.legend="none") doesn't work with coord_flip()

I want to have a horizontal bar chart, but without legend. When I run the script below without coord_flip(), no legend shows. But when I run it with the coord_flip() argument, the legend appaers. I ...
SHW's user avatar
  • 491
3 votes
0 answers
315 views

Why legend does not appear outside plot?

I run code from this answer How to put the legend out of the plot in PyCharm in console (Anaconda environment) and it didn't produced right output I recreated a conda env, but it still does not work. ...
Maciej Dzieżyc's user avatar
3 votes
1 answer
1k views

breaks and values not matching up in plot when using scale_color_manual in ggplot2

I am trying to graph multiple graphs using the same colors (values) for each group I am plotting using scale_color_manual. It seems to work well for many of the graphs, but not all and I cannot seem ...
Megan Ladds's user avatar
3 votes
0 answers
2k views

Show only top 5 values in legend for Pie Chart (Am4 charts)

I have a pie chart with legends made using Am4 charts but I need to display only the top 5 legend values. I wrote the following code: var chart = am4core.create("chartdiv2", am4charts.PieChart); ...
Thanatos's user avatar
  • 292
3 votes
0 answers
3k views

How to change legend scale - folium choropleth map

I have some sort of error with the scale of the legend on my choropleth map in folium. I have tried to use the bin size to change it but can't work out what I am doing wrong. no mater what numbers i ...
Sam's user avatar
  • 81
3 votes
0 answers
2k views

ggplot2: Stacked bar and legend on the top

I am trying to plot my data using stacked bar plot. I want to put the legend on the top of the plot for aesthetics reasons. However, when I do so the order of the does not match the order of the ...
degopwn's user avatar
  • 517
3 votes
0 answers
763 views

Scatter marker and boxplot symbol combined to a single legend key

I want to plot two datasets, the first representing the stage A of a product in development and the second the stage B respectively, using a scatter and boxplot. I used matplotlib's scatter and ...
Hannes's user avatar
  • 73
3 votes
0 answers
11k views

How to change legend labels in ggplot2 for visualizing data in R?

I am using ggplot2 to visualize some data in R. Therefore I use the following command: ggplot(second_sentiment_counts)+ aes(x = sentiment, y = n, fill = as.factor(sentiment)) + geom_bar(stat = "...
Lucinho91's user avatar
  • 195
3 votes
1 answer
2k views

Plotting titles and legends on interactive igraph plot? (R)

I'm having trouble adding a title and legend to the inside of my graph. Is it not possible with tkplot OR plot? dff <- data.frame(a = c(0,1,2,3,4),b = c(3,4,5,6,7)) nod <- data.frame(...
hmnoidk's user avatar
  • 565
3 votes
0 answers
193 views

legend changes unexpectedly with ggplot2

Any idea why this happens? Reversing the order of the legend changes it quite substantially. ggplot(mtcars, aes(x = disp, y = mpg, colour = disp, size = disp)) + geom_point() + ...
RobertMyles's user avatar
  • 2,803
3 votes
0 answers
128 views

How can i adjust the spacing between individual labels in the legend in R?

I am trying to adjust the spaces between individual labels in the legend so that I can see all 9 labels but unfortunately I was not successful. Here is my code to generate the boxplots # raw counts ...
upendra's user avatar
  • 2,179
3 votes
0 answers
424 views

how to update legend data in D3.js

I am working on one project in which I need to plot data on USA map. Here is the link to the code. I am getting logical error in the output. In the drop down menu of attributes, when you first select ...
chinmaykelkar's user avatar

15 30 50 per page
1
2 3 4 5
26