1

Legend outside the plot and adjusting sublot size shrink picture. How is it possible to fix it?

import pandas as pd
import matplotlib.pyplot as plt
a = {'Test1': {1: 21867186, 4: 20145576, 10: 18018537},
'Test2': {1: 23256313, 4: 21668216, 10: 19795367}}

d = pd.DataFrame(a).T
f = plt.figure()

plt.title('Title here!', color='black')

d.plot(kind='bar', ax=f.gca())
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
plt.subplots_adjust(bottom=.25, right=.25)

plt.show()
user977828
  • 7,259
  • 16
  • 66
  • 117
  • Have you tried different adjust values? `plt.subplots_adjust(right=.8)` looks good for me. If it doesn't solve the problem for you, can you be more specific of what is wrong? Maybe include a screenshot in your question? – Igonato May 09 '14 at 07:55
  • You should look at this [excellent answer by Joe Kington](http://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot/4701285#4701285). It may not solve your immediate problem but it may be of help nonetheless. – Ffisegydd May 09 '14 at 08:04

0 Answers0