Difference between revisions of "Python - matplotlib"

From PeformIQ Upgrade
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 10: Line 10:


GUI_TESTS = \
GUI_TESTS = \
  anim.png \
        anim.png \
 
PNG    = \
        anscombe.png \
        alignment_test.png \
        arctest.png \
        axprops_demo.png \
        barchart_demo.png \
        bar_stacked.png \
        box1.png \
        dashticklabel.png \
        dashpointlabel.png \
        date_demo_rrule.png \
        legend_scatter.png \
        polar_scatter.png \
        step_demo.png \
        text_handles.png \
        to_numeric.png \
        transoffset.png \
        two_scales.png \
        stock_demo.png \
        vertical_ticklabels.png \
        zorder_demo.png \


TESTS  = \
TESTS  = \
  anscombe.png \
        anscombe.py \
  arctest.png \
        alignment_test.py \
  axprops_demo.png \
        arctest.py \
  barchart_demo.png \
        axes_props.py \
  bar_stacked.png \
        barchart_demo.py \
  boxplot_demo.png \
        bar_stacked.py \
  dashticklabel.png \
        boxplot_demo.py \
  dashpointlabel.png \
        dashtick.py \
        dashpointlabel.py \
        date_demo_rrule.py \
        legend_scatter.py \
        polar_scatter.py \
        step_demo.py \
        text_handles.py \
        to_numeric.py \
        transoffset.py \
        two_scales.py \
        stock_demo.py \
        vertical_ticklabels.py \
        zorder_demo.py \


#---------------------------------------------------------------------
#---------------------------------------------------------------------


all: $(TESTS)
all:   $(PNG)
 
test:  arctest.png


test: arctest.png
dist:
        tar cvfz matplot_demos.tz Makefile $(TESTS) $(PNG)


#---------------------------------------------------------------------
#---------------------------------------------------------------------


anim.png:
anim.png:
  python ./anim.py
        python ./anim.py


anscombe.png:
anscombe.png:
  python ./anscombe.py
        python ./anscombe.py
 
alignment_test.png:
        python ./alignment_test.py


arctest.png:
arctest.png:
  python ./arctest.py
        python ./arctest.py


axprops_demo.png:
axprops_demo.png:
  python ./axes_props.py
        python ./axes_props.py


barchart_demo.png:
barchart_demo.png:
  python ./barchart_demo.py
        python ./barchart_demo.py


bar_stacked.png:
bar_stacked.png:
  python ./bar_stacked.py
        python ./bar_stacked.py


boxplot_demo.png:
box1.png:
  python ./boxplot_demo.py
        python ./boxplot_demo.py


dashpointlabel.png:
dashpointlabel.png:
  python ./dashpointlabel.py
        python ./dashpointlabel.py


dashticklabel.png:
dashticklabel.png:
  python ./dashtick.py
        python ./dashtick.py
 
date_demo_rrule.png:
        python ./date_demo_rrule.py
 
polar_scatter.png:
        -python ./polar_scatter.py
 
step_demo.png:
        -python ./step_demo.py
 
text_handles.png:
        -python ./text_handles.py
 
to_numeric.png:
        -python ./to_numeric.py
 
transoffset.png:
        python ./transoffset.py
 
two_scales.png:
        python ./two_scales.py
 
legend_scatter.png:
        python ./legend_scatter.py
 
stock_demo.png:
        python ./stock_demo.py
 
vertical_ticklabels.png:
        python ./vertical_ticklabels.py
 
zorder_demo.png:
        python ./zorder_demo.py


#---------------------------------------------------------------------
#---------------------------------------------------------------------
</pre>
</pre>


== AXES Demo ==
== AXES Demo ==
Line 137: Line 209:


[[Category:Python]]
[[Category:Python]]
[[Category:Graphics]]
[[Category:Examples]]

Latest revision as of 14:13, 12 September 2008

Examples

Makefile to Run Demos

#---------------------------------------------------------------------

GUI_TESTS = \
        anim.png \

PNG     = \
        anscombe.png \
        alignment_test.png \
        arctest.png \
        axprops_demo.png \
        barchart_demo.png \
        bar_stacked.png \
        box1.png \
        dashticklabel.png \
        dashpointlabel.png \
        date_demo_rrule.png \
        legend_scatter.png \
        polar_scatter.png \
        step_demo.png \
        text_handles.png \
        to_numeric.png \
        transoffset.png \
        two_scales.png \
        stock_demo.png \
        vertical_ticklabels.png \
        zorder_demo.png \

TESTS   = \
        anscombe.py \
        alignment_test.py \
        arctest.py \
        axes_props.py \
        barchart_demo.py \
        bar_stacked.py \
        boxplot_demo.py \
        dashtick.py \
        dashpointlabel.py \
        date_demo_rrule.py \
        legend_scatter.py \
        polar_scatter.py \
        step_demo.py \
        text_handles.py \
        to_numeric.py \
        transoffset.py \
        two_scales.py \
        stock_demo.py \
        vertical_ticklabels.py \
        zorder_demo.py \

#---------------------------------------------------------------------

all:    $(PNG)

test:   arctest.png

dist:
        tar cvfz matplot_demos.tz Makefile $(TESTS) $(PNG)

#---------------------------------------------------------------------

anim.png:
        python ./anim.py

anscombe.png:
        python ./anscombe.py

alignment_test.png:
        python ./alignment_test.py

arctest.png:
        python ./arctest.py

axprops_demo.png:
        python ./axes_props.py

barchart_demo.png:
        python ./barchart_demo.py

bar_stacked.png:
        python ./bar_stacked.py

box1.png:
        python ./boxplot_demo.py

dashpointlabel.png:
        python ./dashpointlabel.py

dashticklabel.png:
        python ./dashtick.py

date_demo_rrule.png:
        python ./date_demo_rrule.py

polar_scatter.png:
        -python ./polar_scatter.py

step_demo.png:
        -python ./step_demo.py

text_handles.png:
        -python ./text_handles.py

to_numeric.png:
        -python ./to_numeric.py

transoffset.png:
        python ./transoffset.py

two_scales.png:
        python ./two_scales.py

legend_scatter.png:
        python ./legend_scatter.py

stock_demo.png:
        python ./stock_demo.py

vertical_ticklabels.png:
        python ./vertical_ticklabels.py

zorder_demo.png:
        python ./zorder_demo.py

#---------------------------------------------------------------------

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')

Produces:

Axes demo.png

arctest.py

#!/usr/bin/env python

from pylab import *

def f(t):
    'a damped exponential'
    s1 = cos(2*pi*t)
    e1 = exp(-t)
    return multiply(s1,e1)

t1 = arange(0.0, 5.0, .2)


l  = plot(t1, f(t1), 'ro')

setp(l, 'markersize', 30)
setp(l, 'markerfacecolor', 'b')


# show()

savefig('arctest', dpi=150)

Produces Arctest.png