#!/usr/bin/python
# -*- coding: utf8 -*-
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from math import *
code_website = 'http://commons.wikimedia.org/wiki/User:Geek3/mplwp'
try:
import mplwp
except ImportError, er:
print 'ImportError:', er
print 'You need to download mplwp.py from', code_website
exit(1)
name = 'mplwp_arctan_piaxis.svg'
fig = mplwp.fig_standard(mpl)
# add pi to xaxis labels
def flabel(x, i):
return u'{}\u03C0'.format(x).replace('-', u'\u2212')
fig.gca().yaxis.set_major_formatter(mpl.ticker.FuncFormatter(flabel))
# make space for labels
mplwp.set_bordersize(fig, 63.5, 21.5, 18.5, 26.5)
fig.gca().yaxis.set_major_locator(mpl.ticker.MultipleLocator(0.25))
xlim = -5,5; fig.gca().set_xlim(xlim)
ylim = -0.675, 0.675; fig.gca().set_ylim(ylim)
mplwp.mark_axeszero(fig.gca())
x = np.linspace(xlim[0], xlim[1], 5001)
y = [atan(xx)/pi for xx in x]
plt.plot(x, y, label='arctan')
plt.legend(loc='upper center').get_frame().set_alpha(0.9)
plt.savefig(name)
mplwp.postprocess(name)