Don't crop legend.
authorCMDR furrycat <elite@furrycat.net>
Fri, 21 Apr 2017 09:18:56 +0000 (10:18 +0100)
committerCMDR furrycat <elite@furrycat.net>
Fri, 21 Apr 2017 09:18:56 +0000 (10:18 +0100)
plugin/faction/faction.py

index a7bbbca..faf430d 100644 (file)
@@ -1022,7 +1022,7 @@ class Faction(DBConnection):
     fig, ax = plt.subplots()
     for label, entry in data.items():
       plt.plot(entry['x'], entry['y'], label = label)
-    ax.legend(bbox_to_anchor = (1, 0.5), loc = 'center left')
+    legend = ax.legend(bbox_to_anchor = (1, 0.5), loc = 'center left')
 
     plt.title(title)
     plt.xlabel('Date')
@@ -1035,7 +1035,7 @@ class Faction(DBConnection):
     dpi = 96
     fig.set_size_inches(1024.0 / dpi, 768.0 / dpi)
     b = io.BytesIO()
-    plt.savefig(b, format = 'png', dpi = dpi)
+    plt.savefig(b, format = 'png', dpi = dpi, bbox_extra_artists = (legend, ), bbox_inches = 'tight')
     b.seek(0)
     await bot.say(destination, '', attachment = bot.parse_attachment(b.getvalue(), 'influence.png'))
     return True