python - Whitespace in pyplot legend entry? -


i want add spacing between end of legend entry , legend border. i've tried using arguments pyplot.legend haven't found combination works. here's minimal working example:

import matplotlib.pyplot plt import numpy np  x = np.linspace(0.0,1.0,10) y = x  fig = plt.figure() p, = plt.plot(x,y,'-o') plt.legend([p],['$y = x$'], loc='best') plt.show() 

i've tried

plt.legend([p],['$y = x\/$'], loc='best') plt.legend([p],['$y = x{ }$'], loc='best') plt.legend([p],['$y = x\:$'], loc='best') plt.legend([p],['$y = x$ '], loc='best') 

but none of them work. seems pyplot smart , removes trailing whitespace. there way accomplish this?

to give example of why want this, it's balance out space on both sides using 1 marker instead of 2 in legend, see example below. space beside w-y , exp. smaller space on left.

enter image description here

i think can want combination of kwargs borderpad , handletextpad.

(doc)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -