# Author: Ika, 2013-07-24
from pylab import *
import pylab as pl
import numpy as np
# Create a figure of size 8x6 points, 80 dots per inch
pl.figure(figsize=(8,8), dpi=80)
# Create a plot of the cubic function y=(x+4)(x+1)(x-2)/4
x = np.linspace(-5.0,4.0,256, endpoint=True)
y = (x+4)*(x+1)*(x-2)/4
pl.plot(x,y,color="magenta", linewidth=3.0, linestyle="-")
# Set labels
pl.xlim(-5,4)
pl.ylim(-4,7)
# Move the spines
ax = pl.gca()
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.text(-5, 3, r'$y=\frac{1}{4}(x+4)(x+1)(x-2)$', fontsize=20)
# Set up the grid
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
ax.grid(color="grey",linestyle='--',linewidth=1)
# Save the figure to the output SVG file
plt.savefig("Cubic_Function_SVG.svg");