Skip to main content

All Questions

Tagged with
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
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....
Chris Ze Third's user avatar
1 vote
0 answers
34 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. ...
VERBOSE's user avatar
  • 1,105
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
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 ...
Loes Vandenbroucke's user avatar
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 ...
JuanMuñoz's user avatar
1 vote
1 answer
45 views

How to add legend of plotted line in a box plot?

I have plotted a set of data in a boxplot, and I have added a line in the plot. I want to have the labels of the median and mean in the legend, and I have got it. However, I'm also trying to add the ...
lolloa's user avatar
  • 27
0 votes
0 answers
22 views

Line2D multiple colors in legend [duplicate]

I want to create a custom legend. Here, in the example, I create two lines. But for this line, which now is blue, I would like it to be in multiple colors: blue, green, and red. Here is a minimum ...
blahblah's user avatar
0 votes
0 answers
13 views

Matplotlib not changing legend labels for a plot in python package pyAT

So I am attempting to use a python interface of Accelerator Toolbox (pyAT: link here) to simulate the path of a few particles through an energy spectrometer. From this interface, I've utilized a ...
tfs563's user avatar
  • 1
0 votes
0 answers
33 views

Inserting legend in a Matplotlib/Geopandas Map

I've created a incidence map for a city, but now i need to manipulate the legend ( decrease its size, put it bellow the map/graph, insert labels). i've used a json file to plot the territory. Here's ...
gongmaodu's user avatar
1 vote
1 answer
61 views

How to make pyplot Hatches look pretty in the legend

I have a problem and struggle to find a solution, or phrase the question for a search engine. I have many python plots where i use hatches to show exclusions from constraints (so some hatches are not ...
TheMaker845'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
1 vote
1 answer
42 views

Legend for boxplot graph layers

I've made this boxplot graph # Tamanho do gráfico em polegadas plt.figure(figsize=(11, 6)) # Gráfico ax = sns.boxplot(x="CÓD. ESTAÇÃO", y ="FERRO", data=df_FERRO, linewidth=1.0, ...
gongmaodu's user avatar
1 vote
0 answers
57 views

Multiple columns of df show as 1 single label in legend and show how many columns are representing on matplotlib

I have a dataframe that contains temperature of 3 meteorological networks and each ones contains a certain meteorological stations, so the columns 0 to 34 are stations of 'REDMET' meteorological ...
Ferchiz4200's user avatar
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 ...
Norbi's user avatar
  • 103
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?
Tims's user avatar
  • 641
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 ...
Idieh's user avatar
  • 63
-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, ...
ZacharyST's user avatar
  • 676
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, ...
vonbecker's user avatar
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
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 ...
Lidiia's user avatar
  • 33
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 ...
albo's user avatar
  • 33
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
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 = ...
Wiktoria's user avatar
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 ...
josephbags's user avatar
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 ...
My Work's user avatar
  • 2,408
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 ...
AdeDoyle's user avatar
  • 395
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 ...
Shekaib Musa's user avatar

15 30 50 per page
1
2 3 4 5
35