Reputation: 47
I have drawn the following figure. Is it possible to make the figure with length 2 unit & height 1 unit? Also is it possible to change plt.xlabel('time (s)') to plt.xlabel('$\alpha \rightarrow$')?
import matplotlib.pyplot as plt
import numpy as np
t=[0,1,2]
s=[0.05,0.1,0.2]
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
#plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig("test.png")
plt.show()
Upvotes: 2
Views: 508
Reputation: 169544
You answered your own question about the figure size.
For the second question you just need a raw string, e.g.: plt.xlabel(r'$\alpha \rightarrow$')
To make the alpha bold -- as requested in a comment -- it's a little more involved. Per https://tex.stackexchange.com/a/99286 you'd do:
import matplotlib
matplotlib.rc('text', usetex=True)
matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsbsy}"]
t=[0,1,2]
s=[0.05,0.1,0.2]
plt.plot(t, s)
plt.ylabel('voltage (mV)')
plt.xlabel(r'$\pmb{\alpha}$ \rightarrow$')
plt.show()
Upvotes: 1