You can look at the matplotlib documentation, which isn’t too bad, but this might also be helpful.
country | continent | gdp_per_capita | life_expectancy | population | |
---|---|---|---|---|---|
0 | Afghanistan | Asia | 663 | 54.863 | 22856302 |
1 | Albania | Europe | 4195 | 74.200 | 3071856 |
2 | Algeria | Africa | 5098 | 68.963 | 30533827 |
Plotting
Ignore the fact that this is a really dumb plot of nothing.
<matplotlib.axes._subplots.AxesSubplot at 0x10e2db4e0>
Removing the legend
Moving the legend
loc=
…
* 'best'
* 'upper right'
* 'upper left'
* 'lower left'
* 'lower right'
* 'right'
* 'center left'
* 'center right'
* 'lower center'
* 'upper center'
* 'center'
<matplotlib.legend.Legend at 0x10e2446a0>
<matplotlib.legend.Legend at 0x10f0ae9e8>
Changing the title of the legend
<matplotlib.legend.Legend at 0x10f269cc0>
Making it not so busy and complex and shadow-y etc
You can also use an rcParams with a legend.frameon
value of False
<matplotlib.legend.Legend at 0x10f8344a8>
Make it horizontal instead of vertical
<matplotlib.legend.Legend at 0x10fc0a710>
Push it outside
<matplotlib.legend.Legend at 0x110458c50>
<matplotlib.legend.Legend at 0x110efe2b0>
Other options?
Run ax.legend?
to see a lot lot lot more.