#!/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_arcsin_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))
fig.gca().xaxis.set_major_locator(mpl.ticker.MultipleLocator(0.5))
xlim = -1.25,1.25; fig.gca().set_xlim(xlim)
ylim = -0.56, 0.56; fig.gca().set_ylim(ylim)
mplwp.mark_axeszero(fig.gca())
f = lambda y: sin(pi*y)
y = np.linspace(-0.5, 0.5, 5001)
x = [f(yy) for yy in y]
plt.plot(x, y, label='arcsin')
plt.plot([-1,1], [-0.5,0.5], '.', color=fig.gca().lines[-1].get_color())
plt.legend(loc='upper center').get_frame().set_alpha(0.9)
plt.savefig(name)
mplwp.postprocess(name)