#!/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_arccot_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.move_axes(fig, 11, 0)
fig.gca().yaxis.set_major_locator(mpl.ticker.MultipleLocator(0.25))
xlim = -5,5; fig.gca().set_xlim(xlim)
ylim = -0.125, 1.125; fig.gca().set_ylim(ylim)
mplwp.mark_axeszero(fig.gca())
x = np.linspace(xlim[0], xlim[1], 5001)
y = [0.5 - atan(xx)/pi for xx in x]
plt.plot(x, y, label='arccot')
plt.legend(loc='upper center').get_frame().set_alpha(0.9)
plt.savefig(name)
mplwp.postprocess(name)