Pathon math lib.
numpy + SciPy + IPython + matplotlib
- example of plot: http://matplotlib.sourceforge.net/
import matplotlib.pyplot as plt
import numpy as np
x,y = np.random.randn(2,100)
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)
ax1.axhline(0, color='black', lw=2)
ax2 = fig.add_subplot(212, sharex=ax1)
ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)
ax2.axhline(0, color='black', lw=2)
plt.show()
- save graph to file: http://stackoverflow.com/questions/4325733/save-a-subplot-in-matplotlibimport matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
# Make an example plot with two subplots...
fig = plt.figure()
ax1 = fig.add_subplot(2,1,1)
ax1.plot(range(10), 'b-')
ax2 = fig.add_subplot(2,1,2)
ax2.plot(range(20), 'r^')
# Save the full figure...
fig.savefig('full_figure.png')
# Save just the portion _inside_ the second axis's boundaries
extent = ax2.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig('ax2_figure.png', bbox_inches=extent)
# Pad the saved area by 10% in the x-direction and 20% in the y-direction
fig.savefig('ax2_figure_expanded.png', bbox_inches=extent.expanded(1.1, 1.2))
-- plot 3d data: http://matplotlib.sourceforge.net/plot_directive/mpl_examples/mplot3d/lines3d_demo.py
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, label='parametric curve')
ax.legend()
plt.show()
-- PIL load & save image
import Image , ImageDraw
im = Image.open(infile)
im.save(outfile, "JPEG")
draw = ImageDraw.Draw(im) #FAIL to display!
-- plot image loaded by PIL: (FAIL!)
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
s='B:\\3DSolar_ApplTest\\ATS201107\\0720\\WISI0003_sawMark0degLargeThan15\\pair0\\top\\out.tif'
img=mpimg.imread(s)
imgplot = plt.imshow(img)
Axes3D.plot_surface(