legend

custom legend function for matplotlib chart

custom legend function for matplotlib chart Question: Right now when I have dual y-axis and I want to have one legend box for both of my labels I do the following: fig, ax = plt.subplots(1,2) ax0=ax[0].twinx() line1=ax[0].plot([1, 2, 3], [4, 5, 6], ‘b’, lw=1, label=’Line 1′) line2=ax0.plot([1, 2, 3], [6, 5, 4], ‘r’, lw=1, label=’Line …

Total answers: 1

How to remove lines from markers in the legend

How to remove lines from markers in the legend Question: I’ve plotted some data as error bars linked by lines, as you can see from the picture. I would like to show only the markers in the legend (I don’t want to show the lines in the middle of the markers). I don’t want to …

Total answers: 2

Adjusting colorbar legend limits

Adjusting colorbar legend limits Question: I have the following python code to plot a surface contour plot: import matplotlib.pyplot as plt from matplotlib import cm import pandas as pd dx = {‘1’: 1, ‘2’: -1, ‘3’: -1, ‘4’: 1, ‘5’: 0} x = pd.Series(data=dx, index=[‘1’, ‘2’, ‘3’, ‘4’, ‘5’]) dy = {‘1’: 1, ‘2’: 1, …

Total answers: 1

How to have a figure legend and a subplot legend

How to have a figure legend and a subplot legend Question: I would like to plot some data in subplots and I would like to have a legend for the overall figure but also a legend for one of the subplots, where the labels of the subplot should not appear in the figure label. Here …

Total answers: 1

matplotlib legend not showing correctly

matplotlib legend not showing correctly Question: I am trying to plot some data from a csv file. I used the Pandas to load the csv file. I am using sns.lineplot() to plot the lines. But one of the legend is always faulty. It shows a square around one of the legend. plt.figure(dpi=150) lin1 = sns.lineplot(x …

Total answers: 2

matplotlib: labeling of curves

matplotlib: labeling of curves Question: When I create a plot with many curves it would be convenient to be able to label each curve at the right where it ends. The result of plt.legend produces too many similar colors and the legend is overlapping the plot. As one can see in the example below the …

Total answers: 1

How to assign colors to values in a seaborn heatmap

How to assign colors to values in a seaborn heatmap Question: I have a data frame with 15 rows and 15 columns and the values are whole numbers in the range(0-5). I use this data frame to create multiple heatmaps by filtering the data. In the heatmap, I want to assign particular colors to every …

Total answers: 1

"No artists with labels found to put in legend." error when changing the legend size in pyplot

"No artists with labels found to put in legend." error when changing the legend size in pyplot Question: I want to make my legend size bigger in Pyplot. I used this answer to do that. Here is my code. import matplotlib.pyplot as plt import seaborn as sns sns.set_style("whitegrid") plt.rcParams[‘figure.figsize’] = [15, 7] lst = [1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,4,5,6] …

Total answers: 1

Customize legend labels in Geopandas

Customize legend labels in Geopandas Question: I would like to customize the labels on the geopandas plot legend. fig, ax = plt.subplots(figsize = (8,5)) gdf.plot(column = "WF_CEREAL", ax = ax, legend=True, categorical=True, cmap=’YlOrBr’,legend_kwds = {"loc":"lower right"}, figsize =(10,6)) Adding "labels" in legend_kwds does not help. I tried to add labels with legend_kwds in the following …

Total answers: 2

Need legend to communicate color for plotly graph go.Heatmap

Need legend to communicate color for plotly graph go.Heatmap Question: I’m having a bit of trouble trying to figure out how to have the legend indicate color for my plotly graph objects heatmap. The legend only needs to communicate the graph colors and what they mean. Essentially all I need is "Purple = Data Not …

Total answers: 1