0

I am facing a simple problem. Yet, I cannot solve it. I am trying to plot a distribution of three categories. The plotting itself is not a problem. However, changing the title of the legend does not work. What am I missing?

Code

df = pd.read_csv(os.path.join(data_path, "test.csv"))

distplot = sb.displot(df, x="depth", hue="label", kind="kde")
distplot.fig.legend(title='Node type')

plt.show(block=True)

Error

No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.

Example data

label,depth
A,1
A,2
A,3
B,1
B,1
B,4
B,4
B,4
C,1
C,2
C,6
C,6
C,6

Resulting plot

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Tobias
  • 35
  • 1
  • 3

0 Answers0