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,165
questions
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],...
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
37
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
54
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
68
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
44
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
45
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
36
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
33
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
41
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
39
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
20
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
29
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
14
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
51
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
39
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
40
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
31
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
64
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
178
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
46
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....
0
votes
1
answer
42
views
How to reverse legend order without affecting bar order in Plotly R? [duplicate]
I am creating a stacked bar chart using Plotly in R, and the order of the items in the legend is the reverse of the order that I want.
library(dplyr)
library(plotly)
library(forcats)
set.seed(1)
df &...
0
votes
0
answers
14
views
Visnetwork not displaying visLegend properly
I am using the package VisNetwork and one of the attributes of the nodes contains 9 different possibilities, as follows. This is just a minimal example. In my real dataset, the column "family&...
1
vote
1
answer
149
views
Order of ggplot ignoring order of legends
With the following data, I am trying to create a plot as shown, but the order of legends as: mgCST Group, CST Group, Treatment Status. However, ggplot is ignoring all attempts to order the legends
...
-1
votes
1
answer
40
views
Add horizontal lines with according color and legend to ggplot using R
I want to add horizontal lines so that the lines have y-intercept of period and colors according to their obj_name, ie the same colors as the line plot for each object. I succeeded in putting in these ...
1
vote
1
answer
35
views
Multiple columns in legend using ggplot
I have a dataframe (wi_hist_df) that contains three columns (below I have printed a part of it):
weights Frequency Criterion
1 0.2425 2 Criterion_1
2 0.2475 15 Criterion_1
3 0....