Skip to main content

All Questions

1 vote
1 answer
29 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 ...
rcpi's user avatar
  • 51
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 ...
melatonin15's user avatar
  • 2,209
0 votes
1 answer
51 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", ...
Gaslight Deceive Subvert's user avatar
1 vote
1 answer
64 views

Why doesn't sns.barplot legend show all values?

I have the following graph. Why does the last graph legend not contain all labels? It should contain these values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 20, 21] Code: # select only this year ...
John Doe's user avatar
  • 319
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 ...
Yash's user avatar
  • 337
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&...
ciaran haines's user avatar
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, ...
LostinSpatialAnalysis's user avatar
0 votes
1 answer
89 views

Remove style entries from seaborn lineplot legend [duplicate]

I have a pandas dataframe with name, date, strenght, protocol columns. I am plotting a seaborn lineplot with date column as x; strenght column as y; protocol column as hue; name column as style. I ...
Jacopo Busatto's user avatar
0 votes
1 answer
285 views

How to customize the color scatterplot legend handle [duplicate]

I have a seaborn scatterplot with datapoints distinguished by (1) color and (2) marker. This is the minimal code that generates the plot: d = {'x': [1, 2, 3, 4], 'y': [2,4,6,8], 'Set': ["Set 1&...
innakigc's user avatar
0 votes
1 answer
258 views

Duplicated labels in the legend of Seaborn histplot

I am trying to generate a combined histplot with two datasets together with the following codes _,bins = np.histogram([150, 600], bins=30) alpha = 0.4 fig, ax = plt.subplots(1,1) sns.histplot(df1['...
zzrrhhh's user avatar
  • 11
1 vote
1 answer
226 views

How to add a legend to a heatmap

I am using a small variation of this really nice code to plot a heatmap. import matplotlib import seaborn as sns import numpy as np from matplotlib.colors import ListedColormap np.random.seed(7) A = ...
Simd's user avatar
  • 20.9k
0 votes
2 answers
429 views

How to modify a legend with hatches

I have created a barplot with hatches with the code below: import matplotlib.pyplot as plt import seaborn as sns tips = sns.load_dataset("tips") hatches = ['\\\\', '//'] fig, ax = plt....
Ernesto's user avatar
  • 187
3 votes
2 answers
900 views

How to add hatches to histplot bars and legend

I created a bar plot with hatches using seaborn. I was also able to add a legend that included the hatch styles, as shown in the MWE below: import matplotlib.pyplot as plt import seaborn as sns tips =...
Ernesto's user avatar
  • 187
3 votes
2 answers
163 views

How to reposition Figure legends into subfigures

I am new to this, trying to plot 2 subfigures horizontal with sample data using Matplotlib and Seaborn library in Jupyter Notebook, the 2 sub-charts come out alright, but the 2 legends overlap each ...
user21559775's user avatar
0 votes
0 answers
366 views

Seaborn boxplot legend ignoring colors [duplicate]

I have a boxplot in Seaborn/Matplotlib for multiple categorical data: The problem is the legend part does not match with the plot color. data = pd.DataFrame.from_dict(data) print(data.head()) ...
m0ss's user avatar
  • 432

15 30 50 per page
1
2 3 4 5
7