Home > Mobile >  How to change the legend location for pandas subplots
How to change the legend location for pandas subplots

Time:11-18

I'm trying to create a pandas plot with a large number of subplots, 58 in this case. The data is wide form in a format similar to this:

df = 

Date It1 It2 It3... Itn 
0    x    x   x      n
1    x    x   x      n
2    x    x   x      n
3    x    x   x      n

I have been able to create the plot no problem with pandas plot:

rows = df.shape[1]//2
df.plot(legend = True, subplots = True, layout = (rows,5), grid=True, title="Labs", sharex=True, sharey=False,figsize=(12,32),)
plt.show()

But am having trouble setting the position of the legend so all of the graphs are legible, this is an example of how the currently look:

enter image description here

I've tried both solutions in this other stack overflow post - enter image description here

  • Related