I am trying to make some publications, but I ran into a little problem. Apparently, by default, matplotlib label marks and legend records are weighted heavier than axis markers. In any case, in order to make the legend axis / legend labels equal in weight with the tick marks?
import matplotlib.pyplot as plt import numpy as np plt.rc('text',usetex=True) font = {'family':'serif','size':16} plt.rc('font',**font) plt.rc('legend',**{'fontsize':14}) x = np.linspace(0,2*np.pi,100) y = np.sin(x) fig = plt.figure(figsize=(5,5)) p1, = plt.plot(x,y) p2, = plt.plot(x,x**2) plt.xlabel('x-Axis') plt.ylabel('y-Axis') plt.legend([p1,p2],['Sin(x)','x$^2$']) plt.gcf().subplots_adjust(left=0.2) plt.gcf().subplots_adjust(bottom=0.15) plt.savefig('Test.eps',bbox_inches='tight',format='eps') plt.show()
I can use math mode, but a problem (annoyance) occurs when I have a suggestion for a label, i.e.
plt.xlabel('$\mathrm{This is the x-axis}$')
which compresses it all together. I can fix it using
plt.xlabel('$\mathrm{This\: is\: the\: x-axis}$')
but this requires many punctuation marks. I was hoping there was something that I could change that would allow me to bypass the \mathrm{} format and use the standard TeX format.
Another option I tried used \text instead of \mathrm , but it seems like the Python interpreter won't recognize this without loading the amsmath package. I also tried:
import matplotlib import matplotlib.pyplot as plt import numpy as np plt.rc('text',usetex=True) font = {'family':'serif','size':16} plt.rc('font',**font) plt.rc('legend',**{'fontsize':14}) matplotlib.rcParams['text.latex.preamble']=[r'\usepackage{amsmath}'] x = np.linspace(0,2*np.pi,100) y = np.sin(x) fig = plt.figure(figsize=(5,5)) p1, = plt.plot(x,y) p2, = plt.plot(x,x**2) plt.xlabel(r'$\text{this is the x-Axis}$') plt.ylabel('$y-Axis$') plt.legend([p1,p2],['Sin(x)','x$^2$']) plt.gcf().subplots_adjust(left=0.2) plt.gcf().subplots_adjust(bottom=0.15) plt.savefig('Test.eps',bbox_inches='tight',format='eps') plt.show()
It also does not return the desired result.