I want to add some spacing between the end of the legend entry and the legend border. I've tried using the arguments for pyplot.legend
but I haven't found a combination that works. Here's a minimal working example:
import matplotlib.pyplot as plt
import numpy as 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. It seems pyplot
is too smart and removes any trailing whitespace. Is there any way to accomplish this?
To give you an example of why I want this, it's to balance out space on both sides with using one marker instead of two in the legend, see example below. The space beside the W-Y and Exp. is much smaller than the space on the left.