legend

Exclude hue-variable from legend

Exclude hue-variable from legend Question: I struggle finding a way of properly displaying only the labels respective to the markers in a scatterplot. My code looks as follows: fig, ax = plt.subplots(1,1) plot_white = sns.scatterplot(data=df_white, x=’EngCorr_Player’, y=’EngCorr_Opponent’, hue=’Elo_Opponent’, ax=ax, marker=’D’, label=’White’) plot_black = sns.scatterplot(data=df_black, x=’EngCorr_Player’, y=’EngCorr_Opponent’, hue=’Elo_Opponent’, ax=ax, marker=’X’, s=140, label=’Black’) ax.legend() plt.show() The problem …

Total answers: 1

Include legend for go.scattermapbox subplot figure – Plotly

Include legend for go.scattermapbox subplot figure – Plotly Question: The following figure produces two subplots using scattermapbox in Plotly. I’ve included a function that assigns a specific color to each unique category. This all works fine but I’m hoping to include a legend that describes each color and category. Using below, there are two subplots …

Total answers: 1

Matplotlib: display legend keys for lines as patches by default

Matplotlib: display legend keys for lines as patches by default Question: For background, see the legend guide. I want to display legend keys for Line2D objects as Patches (with the same color and label), by default. What is the cleanest way to do this? I tried using update_default_handler_map with a handler_map but keep getting errors. …

Total answers: 3

How to create separate legend sections for colors and markers

How to create separate legend sections for colors and markers Question: I would like to plot two features in the same plot. My problem is with the legend. I would like to have one legend for colors(species) and one for the marker (Label defined by me). And I don’t need to repeat the colors in …

Total answers: 2

How do I find the size of a legend in a figure?

How do I find the size of a legend in a figure? Question: The answer to How to include the outside legend into the generated file? is predicated on figuring out the size of a legend in inches. How do I do that? legend inherits from artist and neither mentions size. Asked By: sds || …

Total answers: 1

How to include the outside legend into the generated file?

How to include the outside legend into the generated file? Question: I am plotting many lines on several axes, so I have a several fairly busy plots, thus I need to place the legend outside of the figure: import numpy as np nrows = 4 fig = plt.figure(figsize=(6, 2*nrows)) axes = fig.subplots(nrows=nrows, ncols=1) names = …

Total answers: 2

How to move or remove the legend from a seaborn Jointgrid

How to move or remove the legend from a seaborn JointGrid or jointplot Question: How to remove the legend in the seaborn.JoingGrid plot? The reference code is like below: import matplotlib.pyplot as plt import seaborn as sns penguins = sns.load_dataset("penguins") g = sns.JointGrid(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species") g.plot_joint(sns.scatterplot) sns.boxplot(data=penguins, x=g.hue, y=g.y, ax=g.ax_marg_y) sns.boxplot(data=penguins, y=g.hue, x=g.x, ax=g.ax_marg_x) …

Total answers: 1

Add legend to chart with data from different columns

Add legend to chart with data from different columns Question: How do I add a legend to a chart where I am showing data from more than one column? The legend isn’t appearing automatically and if I use ax.legend() then I get an error message like this: [WARNING] No artists with labels found to put …

Total answers: 1