All Questions
Tagged with legend matplotlib
1,030
questions
0
votes
1
answer
76
views
How can I plot multiple legends for multiple geopandas plot layers?
I want two show both legends for both of my plot layers but it shows only just one legend. How can I fix this?
import geopandas
from shapely.geometry import Point
from shapely.geometry import Polygon
...
0
votes
1
answer
32
views
Do gca().lines and legend.get_lines() return the lines in the same order?
Do gca().lines and legend.get_lines() return the lines in the same corresponding order?
If not, is there a way to get corresponding legend lines from gca().lines?
1
vote
1
answer
181
views
How to make a legend with line and markers with different fillstyles?
I am unsure of how to reproduce the following lines/marker combination in matplotlib:
Note that the legend has both the line and the marker correctly. The best I could find in the matplotlib ...
-1
votes
1
answer
112
views
Cannot Rotate Legend Horizontally in GeoPandas
I am trying to plot California counties and color them by their FIPS code. The sample code from the GeoPandas website is:
chicago.plot(
column="POP2010",
legend=True,
...
0
votes
1
answer
58
views
Multiple column legends in Matplotlib
I created a single stacked horizontal bar chart which illustrates the values in a (normalized) series using:
data = df['state'].value_counts(normalize=True).to_frame()
data.T.plot.barh(stacked=True, ...
2
votes
1
answer
60
views
Seaborn heatmap legend disturb the plots order with subplots
I have 2 dataframes like this:
df1 = pd.DataFrame(np.random.randint(0,50,size=(5,5)), columns=list('ABCDE'))
df2 = pd.DataFrame(np.random.randint(0,50,size=(5,5)), columns=list('FGHIJ'))
I want to ...
1
vote
1
answer
200
views
Combine catplot legend with other legends in seaborn
I want to combine multiple plot legends with a catplot legend and place the single result in the upper right. I also want to replace the labels on both. Examples - {"avg tip":"average&...
3
votes
1
answer
129
views
Custom legend for the plot with lines changing colour
I want to plot two error bars plots with lines changing colour, one going from pink to blue, and another from blue to pink. I did not find a way to do this with plt.errorbar(), but managed to find a ...
1
vote
1
answer
231
views
Legend for contourf in matplotlib [duplicate]
Is there a way put a legend for a contourf plot in matplotlib?
In matlab it's possible to put one like the example picture shown below.
I am aware of both these questions posted previously:
How do you ...
0
votes
2
answers
217
views
How to reverse order of legend for horizontal stacked bar chart in seaborn?
I have the following code that generates a horizontal stacked bar chart in python, using seaborn.
sns.set_style('white')
ax = sns.histplot(
data=temp, y='tmp', weights='Weight', hue=field,
...
1
vote
2
answers
61
views
matplotlib scatter plot legend not dependent on the colour of the point
I want to make my legend to the scatter plot not dependent on the colour of the point. The simple example is below:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
fake_data = ...
1
vote
1
answer
82
views
Choosing elements for a legend in Python
I am using py.plot to display the upper and lower bounds of confidence intervals (shaded in between). I would like to label each pair of bounds with the item they are measuring. However, Python seems ...
0
votes
1
answer
226
views
Legend in matplotlib jumps around with minimal change to bbox_to_anchor parameters
I have this issue in matplotlib that drives me crazy. I want to position the legend within the plot to be in a certain position, for example, in this case, in the top left corner (matching the corner ...
0
votes
0
answers
7
views
How can I include two categories of label (colour coded and shapes) in a single legend for a single dataset using a matplotlib scatterplot?
I have a dataset, texts, that I want to display using a scatterplot. The texts represented in this dataset have different authors, and are written in different languages. I want to represent the ...
2
votes
1
answer
172
views
How to have a combined legend for colors and marker types
I frequently generate complex plots and strive to simplify the legends. In this particular instance, I am plotting data categorized by multiple models and temperature bands. I want to include two ...