Difference between revisions of "Python - matplotlib"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) |
PeterHarding (talk | contribs) |
||
Line 2: | Line 2: | ||
* [http://www.scipy.org/Cookbook/Matplotlib?action=show&redirect=wikis%2Ftopical+software%2FMatplotlibCookbook SciPy Wiki] | * [http://www.scipy.org/Cookbook/Matplotlib?action=show&redirect=wikis%2Ftopical+software%2FMatplotlibCookbook SciPy Wiki] | ||
* [http://www.scipy.org/Cookbook/Matplotlib/UsingTex Using TeX with matplotlib] | * [http://www.scipy.org/Cookbook/Matplotlib/UsingTex Using TeX with matplotlib] | ||
= Examples = | |||
== AXES Demo -- | |||
#!/usr/bin/env python | |||
from pylab import * | |||
# create some data to use for the plot | |||
dt = 0.001 | |||
t = arange(0.0, 10.0, dt) | |||
r = exp(-t[:1000]/0.05) # impulse response | |||
x = randn(len(t)) | |||
s = convolve(x,r)[:len(x)]*dt # colored noise | |||
# the main axes is subplot(111) by default | |||
plot(t, s) | |||
axis([0, 1, 1.1*amin(s), 2*amax(s) ]) | |||
xlabel('time (s)') | |||
ylabel('current (nA)') | |||
title('Gaussian colored noise') | |||
# this is an inset axes over the main axes | |||
a = axes([.65, .65, .2, .2], axisbg='y') | |||
n, bins, patches = hist(s, 400, normed=1) | |||
title('Probability') | |||
setp(a, xticks=[], yticks=[]) | |||
# this is another inset axes over the main axes | |||
a = axes([0.2, 0.65, .2, .2], axisbg='g') | |||
plot(t[:len(r)], r) | |||
title('Impulse response') | |||
setp(a, xlim=(0,.2), xticks=[], yticks=[]) | |||
#show() | |||
#savefig('../figures/axes_demo.eps') | |||
#savefig('../figures/axes_demo.png') | |||
savefig('axes_demo.png') | |||
== XX == |
Revision as of 16:29, 17 December 2007
Examples
== AXES Demo --
#!/usr/bin/env python from pylab import * # create some data to use for the plot dt = 0.001 t = arange(0.0, 10.0, dt) r = exp(-t[:1000]/0.05) # impulse response x = randn(len(t)) s = convolve(x,r)[:len(x)]*dt # colored noise # the main axes is subplot(111) by default plot(t, s) axis([0, 1, 1.1*amin(s), 2*amax(s) ]) xlabel('time (s)') ylabel('current (nA)') title('Gaussian colored noise') # this is an inset axes over the main axes a = axes([.65, .65, .2, .2], axisbg='y') n, bins, patches = hist(s, 400, normed=1) title('Probability') setp(a, xticks=[], yticks=[]) # this is another inset axes over the main axes a = axes([0.2, 0.65, .2, .2], axisbg='g') plot(t[:len(r)], r) title('Impulse response') setp(a, xlim=(0,.2), xticks=[], yticks=[]) #show() #savefig('../figures/axes_demo.eps') #savefig('../figures/axes_demo.png') savefig('axes_demo.png')