It is way too hard to tell #matplotlib, "please put my legend outside the graph on the right hand side."
-
-
Replying to @generativist
def plt_legend_xyrel(plt, xrel, yrel, *args, **kwargs): ax = plt.gca() xlim , ylim = ax.get_xlim(), ax.get_ylim() xloc = xlim[0] + xrel * (xlim[1] - xlim[0]) yloc = ylim[0] + yrel * (ylim[1] - ylim[0]) plt.legend(*args, **kwargs, loc=[xloc, yloc])
1 reply 1 retweet 2 likes -
Replying to @btskinn @generativist
Then pass xrel as ~1.05 and yrel as ~0.33; tweak to taste.
1 reply 0 retweets 1 like -
Replying to @btskinn
That's sorta what I have from a SO comment. But, wait... ...what is this... https://matplotlib.org/examples/pylab_examples/figlegend_demo.html …
1 reply 0 retweets 1 like -
Replying to @generativist
Ahh, interesting -- defining sub-axes on only a portion of the overall figure canvas.
1 reply 0 retweets 1 like -
Replying to @btskinn @generativist
Yeah, doing it this way probably is better for things like subplots... if you draw outside the axes with a full-panel axes, it would probably draw on top of neighboring stuff, whereas doing it this way would (probably?) do better at avoiding collisions.
1 reply 0 retweets 1 like -
Replying to @btskinn
A three row subplot is what caused my frustration. I have a solution like yours but it's so damn ugly, codebloat wise. I just want to say legend_to_the_right(fig)
1 reply 0 retweets 0 likes
(Plus, I'm drawing the legend to the right of the center one in a way that works but kinda betrays my hack)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.