Created
October 21, 2016 00:26
-
-
Save johanndt/01c9fa64a3e889abb336cff1ccbbacfb to your computer and use it in GitHub Desktop.
Revisions
-
johanndt created this gist
Oct 21, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ from PIL import ImageFont import toyplot series_names = ["Series 1", "Series 2", "Series 3"] canvas = toyplot.Canvas(width=300, height=300) font = ImageFont.load_default() next_x = 0 for legend in series_names: canvas.legend([ (legend, {"shape": "s", "mstyle":{"fill":"green", "stroke": "none"}}) ], rect=(next_x, 0, 200, 30)) # some trial and error was used to scale this right next_x = next_x + 30 + (1.2 * font.getsize(legend)[0])