import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib as mpl
import sys
label_size = 18
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
As an example we consider the sine
and cosine
function, $f(x)$, in the domain $x\in[-2\pi, 2\pi]$.
x = np.linspace(-2*np.pi, 2*np.pi, 100)
plt.subplots(figsize=(6,4))
plt.plot(x, np.sin(x), label = r"$sin(x)$")
plt.plot(x, np.cos(x), label = r"$cos(x)$")
plt.xlabel('$x$', fontsize = 22)
plt.ylabel(r'$f(x)$', fontsize = 22)
plt.xticks([-2*np.pi, -np.pi,0, np.pi, 2*np.pi], [ r"$-2\pi$", r"$-\pi$", r"$0$", r"$\pi$", r"$2\pi$"])
plt.xlim(xmin = -8, xmax = 8)
plt.legend(prop={'size': 16}, frameon = False, handlelength = .5, loc = "best");
#plt.savefig('basic1D_Ej1C' + '.png', format='png', dpi= 150, bbox_inches='tight');
print(f"Python version: {sys.version}")
print(" ")
print("numpy == ", np.__version__)
print("matplotlib == ", mpl.__version__)
Python version: 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] numpy == 1.14.0 matplotlib == 2.1.2