diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af3a366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Icon? +.DS_Store +*.pyc +*~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ac456d5 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +MAKE = /usr/bin/make +RST2HTML = rst2html.py +RST2LATEX = rst2latex.py +STYLESHEET = dana.css +RST2HTML_OPTIONS = --strip-comments \ + --report=3 \ + --stylesheet=$(STYLESHEET) \ + --link-stylesheet +RST2LATEX_OPTIONS = --strip-comments \ + --report=3 \ + --use-latex-toc + +SOURCES = $(wildcard *.rst) +HTML_OBJECTS = $(subst .rst,.html, $(SOURCES)) +LATEX_OBJECTS = $(subst .rst,.tex, $(SOURCES)) + +html: $(HTML_OBJECTS) + +latex: $(LATEX_OBJECTS) + +%.html: %.rst Makefile + @echo " - $@" + @$(RST2HTML) $(RST2HTML_OPTIONS) $< $@ + +%.tex: %.rst Makefile + @echo " - $@" + @$(RST2LATEX) $(RST2LATEX_OPTIONS) $< $@ + +clean: + @-rm -f $(LATEX_OBJECTS) $(HTML_OBJECTS) + +distclean: clean + @-rm -f `find . -name "*~"` + + diff --git a/dana.css b/dana.css new file mode 100644 index 0000000..a63265f --- /dev/null +++ b/dana.css @@ -0,0 +1,361 @@ +@import url("reset.css"); + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Body │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +body { + color: #333333; + font-family: "optima", "lucida grande", "lucida sans unicode", + verdana, arial, helvetica, sans-serif; + font-size: 1.1em; + line-height: 1.5em; + margin-top: 0em; +} + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Document │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +div.document { + margin-top: 50px; + margin-bottom: 5em; + margin-left: 250px; +/* margin-right: 5em;*/ + margin-right: 10%; +} + +h1, h2, h3, h4, h5, h6 { + font-family: "futura", "lucida grande", "lucida sans unicode", + verdana, arial, helvetica, sans-serif; + font-weight: normal; + clear: both; +} + +h1 { + font-size: 2em; + margin-top: 2em; + padding-top: 2em; + margin-bottom: 1em; +} + +h2 { + font-size: 1.25em; + margin-top: 3em; + margin-bottom: 1em; + color: #326598; + padding-left: 2em; + margin-left: -2em; + margin-right: 25%; + padding-bottom: .5em; + padding-top: 2em; + border-bottom: 2px solid #326598; +} + +h3 { + font-size: 1em; + margin-top: 3em; + margin-bottom: 1em; + border-bottom: 1px solid #efefef; + color: #326598; +} + +h1.title { + margin-bottom: 0.0em; + padding-bottom: 0.0em; +} +h2.subtitle { + font-size: 1.0em; + padding-top: 0.5em; + margin-top: 0.0em; + color: #999; + border-bottom: none; +} + +p { + margin-bottom: 1em; +} + +strong { + font-weight: bold; +} + +em { + font-style: italic; +} + +a { + color: #326598; + text-decoration: none; +} + +a:hover { + color: #326598; + text-decoration: underline; +} + +hr { + margin-top: 1em; + border: 0; +} + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Image │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +img { + text-align : left; +} + + +.align-right { + float: right; +} + +.aling-left { + float: left; +} + + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Figure │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +.figure +{ + margin-top: 1em; + margin-bottom: 1em; +} + + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Math │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +img.math { + vertical-align: middle; +} +div.body div.math p { + text-align: left; +} +span.eqno { + float: right; +} + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Table │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +table +{ + margin-bottom: 2em; +} +th.head +{ + font-weight: bold; + text-align: left; + border-bottom: 1px solid black; + padding-right: .5em; +} + +th.field-name +{ + font-weight: bold; + text-align: left; + padding-right: 1em; +} + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Code │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ +tt { + font-family: monospace; +} +pre { + padding: .5em; + line-height: 1.25em; + border-left: 3px solid #cccccc; + background-color: #ffffff; + font-family: monospace; + margin-bottom: 1em; + + whitewhite-space: pre-wrap; /* css-3 */ + whitewhite-space: -pre-wrap; /* Opera 4-6 */ + whitewhite-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5+ */ + whitewhite-space: -moz-pre-wrap; /* Older Versions of Mozilla */ +} + + +dl.docutils > dd { + margin-left: 2em; +/* font-size: 90%;*/ +} + +dl.docutils > dt { + font-style: italic; + color: #000099; +} +.classifier { + font-style: normal; + color: #000000; +} +.classifier-delimiter { + font-style: normal; + color: #000000; +} + +dl > dt { + font-family: monospace; +} +dl.method, dl.attribute, dl.function, dl.class { + margin-bottom: 1em; +} +dl.class > dt, dl.function > dt, dl.method > dt, dl.attribute > dt { + padding: .25em; + margin-top: 2em; + background: #eeeeee; +} +.descname { + font-weight: bold; +} + + + +/* + * ┌──────────────────────────────────────────────────────────────────────────┐ + * │ Table Of Content │ + * └──────────────────────────────────────────────────────────────────────────┘ + */ + +/* Global */ +.toctree-wrapper { + padding-bottom: 3em; +} +.toctree-wrapper ul { + list-style-type:none; + padding-bottom: 0; +} +/* +.toctree-l1 { + margin-bottom: 1em; +} +*/ +.toctree-l2 { + padding-left: 2em; +} + +/* Local */ +li > ul > li { + padding-left: 2em; +} + +div.document .contents { + margin-bottom: 5em; +} +div.document .topic-title { + margin-top: 2em; + font-weight: bold; +} +.contents ul { + list-style-type:none; + padding-bottom: 0; +} + + + +/* ------------------------------------------------------------------------- + Admonition + ------------------------------------------------------------------------- */ +div.admonition, div.note { + float: left; + line-height: 1.5em; + font-size: 80%; + margin: 0; + padding: 3px 5px; + margin-left: -220px; + width: 200px; + border-left: 1px solid #cccccc; +} +div.admonition p, div.note p { + text-align: left; + margin: 0; + padding: 0; +} + +div.admonition .first, div.note .first { + font-weight: bold; +} + + + +/* ------------------------------------------------------------------------- + Header + ------------------------------------------------------------------------- */ +div.header { + padding-top: 25px; + padding-left:15px; +} + +/* ------------------------------------------------------------------------- + Footer + ------------------------------------------------------------------------- */ +div.footer { + font-family: "futura", "lucida grande", "lucida sans unicode", + verdana, arial, helvetica, sans-serif; + font-size: 75%; + line-height: 1.5em; + position: fixed; + left: 0; + bottom: 0; + background-color: #EEE; + width: 100%; + border-top: 1px solid; +} +div.footer table { + width: 98%; + margin: auto; +} +div.footer table td a { + color: #777; + text-decoration: none; +} +div.footer td.left { + text-align: left; + width: 25%; +} +div.footer td.center { + text-align: center; + width: 50%; +} +div.footer .current { + background: black; + color:white; + margin: 0; + padding-right: .25em; + padding-left: .25em; +} + +div.footer td.center a { + padding-right: .25em; + padding-left: .25em; +} + +div.footer td.right { + text-align: right; + width: 25%; +} diff --git a/figures/aliased.png b/figures/aliased.png new file mode 100644 index 0000000..2c89d86 Binary files /dev/null and b/figures/aliased.png differ diff --git a/figures/alpha.png b/figures/alpha.png new file mode 100644 index 0000000..11c9954 Binary files /dev/null and b/figures/alpha.png differ diff --git a/figures/antialiased.png b/figures/antialiased.png new file mode 100644 index 0000000..3ff6992 Binary files /dev/null and b/figures/antialiased.png differ diff --git a/figures/arrow.png b/figures/arrow.png new file mode 100644 index 0000000..5a3757b Binary files /dev/null and b/figures/arrow.png differ diff --git a/figures/axes-2.png b/figures/axes-2.png new file mode 100644 index 0000000..1b697b2 Binary files /dev/null and b/figures/axes-2.png differ diff --git a/figures/axes.png b/figures/axes.png new file mode 100644 index 0000000..bcc255f Binary files /dev/null and b/figures/axes.png differ diff --git a/figures/bar.png b/figures/bar.png new file mode 100644 index 0000000..c46a3be Binary files /dev/null and b/figures/bar.png differ diff --git a/figures/bar_ex.png b/figures/bar_ex.png new file mode 100644 index 0000000..43d91af Binary files /dev/null and b/figures/bar_ex.png differ diff --git a/figures/barh.png b/figures/barh.png new file mode 100644 index 0000000..4b25717 Binary files /dev/null and b/figures/barh.png differ diff --git a/figures/boxplot.png b/figures/boxplot.png new file mode 100644 index 0000000..d1e6d80 Binary files /dev/null and b/figures/boxplot.png differ diff --git a/figures/broken_barh.png b/figures/broken_barh.png new file mode 100644 index 0000000..24a5c37 Binary files /dev/null and b/figures/broken_barh.png differ diff --git a/figures/cmap-Accent.png b/figures/cmap-Accent.png new file mode 100644 index 0000000..700cf1e Binary files /dev/null and b/figures/cmap-Accent.png differ diff --git a/figures/cmap-Blues.png b/figures/cmap-Blues.png new file mode 100644 index 0000000..631646c Binary files /dev/null and b/figures/cmap-Blues.png differ diff --git a/figures/cmap-BrBG.png b/figures/cmap-BrBG.png new file mode 100644 index 0000000..144f6e9 Binary files /dev/null and b/figures/cmap-BrBG.png differ diff --git a/figures/cmap-BuGn.png b/figures/cmap-BuGn.png new file mode 100644 index 0000000..f5d4efa Binary files /dev/null and b/figures/cmap-BuGn.png differ diff --git a/figures/cmap-BuPu.png b/figures/cmap-BuPu.png new file mode 100644 index 0000000..8731c76 Binary files /dev/null and b/figures/cmap-BuPu.png differ diff --git a/figures/cmap-CMRmap.png b/figures/cmap-CMRmap.png new file mode 100644 index 0000000..6cc6d4a Binary files /dev/null and b/figures/cmap-CMRmap.png differ diff --git a/figures/cmap-Dark2.png b/figures/cmap-Dark2.png new file mode 100644 index 0000000..6fc8680 Binary files /dev/null and b/figures/cmap-Dark2.png differ diff --git a/figures/cmap-GnBu.png b/figures/cmap-GnBu.png new file mode 100644 index 0000000..dc076c6 Binary files /dev/null and b/figures/cmap-GnBu.png differ diff --git a/figures/cmap-Greens.png b/figures/cmap-Greens.png new file mode 100644 index 0000000..2970949 Binary files /dev/null and b/figures/cmap-Greens.png differ diff --git a/figures/cmap-Greys.png b/figures/cmap-Greys.png new file mode 100644 index 0000000..f4d7473 Binary files /dev/null and b/figures/cmap-Greys.png differ diff --git a/figures/cmap-OrRd.png b/figures/cmap-OrRd.png new file mode 100644 index 0000000..0a73ef5 Binary files /dev/null and b/figures/cmap-OrRd.png differ diff --git a/figures/cmap-Oranges.png b/figures/cmap-Oranges.png new file mode 100644 index 0000000..e85d187 Binary files /dev/null and b/figures/cmap-Oranges.png differ diff --git a/figures/cmap-PRGn.png b/figures/cmap-PRGn.png new file mode 100644 index 0000000..6993070 Binary files /dev/null and b/figures/cmap-PRGn.png differ diff --git a/figures/cmap-Paired.png b/figures/cmap-Paired.png new file mode 100644 index 0000000..2aae307 Binary files /dev/null and b/figures/cmap-Paired.png differ diff --git a/figures/cmap-Pastel1.png b/figures/cmap-Pastel1.png new file mode 100644 index 0000000..d3a4cf9 Binary files /dev/null and b/figures/cmap-Pastel1.png differ diff --git a/figures/cmap-Pastel2.png b/figures/cmap-Pastel2.png new file mode 100644 index 0000000..6150985 Binary files /dev/null and b/figures/cmap-Pastel2.png differ diff --git a/figures/cmap-PiYG.png b/figures/cmap-PiYG.png new file mode 100644 index 0000000..aaf7759 Binary files /dev/null and b/figures/cmap-PiYG.png differ diff --git a/figures/cmap-PuBu.png b/figures/cmap-PuBu.png new file mode 100644 index 0000000..8151162 Binary files /dev/null and b/figures/cmap-PuBu.png differ diff --git a/figures/cmap-PuBuGn.png b/figures/cmap-PuBuGn.png new file mode 100644 index 0000000..0b2b99b Binary files /dev/null and b/figures/cmap-PuBuGn.png differ diff --git a/figures/cmap-PuOr.png b/figures/cmap-PuOr.png new file mode 100644 index 0000000..675fa96 Binary files /dev/null and b/figures/cmap-PuOr.png differ diff --git a/figures/cmap-PuRd.png b/figures/cmap-PuRd.png new file mode 100644 index 0000000..6c630c7 Binary files /dev/null and b/figures/cmap-PuRd.png differ diff --git a/figures/cmap-Purples.png b/figures/cmap-Purples.png new file mode 100644 index 0000000..273618a Binary files /dev/null and b/figures/cmap-Purples.png differ diff --git a/figures/cmap-RdBu.png b/figures/cmap-RdBu.png new file mode 100644 index 0000000..29b51f8 Binary files /dev/null and b/figures/cmap-RdBu.png differ diff --git a/figures/cmap-RdGy.png b/figures/cmap-RdGy.png new file mode 100644 index 0000000..5016ff2 Binary files /dev/null and b/figures/cmap-RdGy.png differ diff --git a/figures/cmap-RdPu.png b/figures/cmap-RdPu.png new file mode 100644 index 0000000..94d0fbb Binary files /dev/null and b/figures/cmap-RdPu.png differ diff --git a/figures/cmap-RdYlBu.png b/figures/cmap-RdYlBu.png new file mode 100644 index 0000000..02fe975 Binary files /dev/null and b/figures/cmap-RdYlBu.png differ diff --git a/figures/cmap-RdYlGn.png b/figures/cmap-RdYlGn.png new file mode 100644 index 0000000..abbc8b4 Binary files /dev/null and b/figures/cmap-RdYlGn.png differ diff --git a/figures/cmap-Reds.png b/figures/cmap-Reds.png new file mode 100644 index 0000000..bf8345f Binary files /dev/null and b/figures/cmap-Reds.png differ diff --git a/figures/cmap-Set1.png b/figures/cmap-Set1.png new file mode 100644 index 0000000..bd19b48 Binary files /dev/null and b/figures/cmap-Set1.png differ diff --git a/figures/cmap-Set2.png b/figures/cmap-Set2.png new file mode 100644 index 0000000..293fdc7 Binary files /dev/null and b/figures/cmap-Set2.png differ diff --git a/figures/cmap-Set3.png b/figures/cmap-Set3.png new file mode 100644 index 0000000..74e0d87 Binary files /dev/null and b/figures/cmap-Set3.png differ diff --git a/figures/cmap-YlGn.png b/figures/cmap-YlGn.png new file mode 100644 index 0000000..28886cb Binary files /dev/null and b/figures/cmap-YlGn.png differ diff --git a/figures/cmap-YlGnBu.png b/figures/cmap-YlGnBu.png new file mode 100644 index 0000000..8d66720 Binary files /dev/null and b/figures/cmap-YlGnBu.png differ diff --git a/figures/cmap-YlOrBr.png b/figures/cmap-YlOrBr.png new file mode 100644 index 0000000..a4caac1 Binary files /dev/null and b/figures/cmap-YlOrBr.png differ diff --git a/figures/cmap-YlOrRd.png b/figures/cmap-YlOrRd.png new file mode 100644 index 0000000..5076254 Binary files /dev/null and b/figures/cmap-YlOrRd.png differ diff --git a/figures/cmap-afmhot.png b/figures/cmap-afmhot.png new file mode 100644 index 0000000..c9acd27 Binary files /dev/null and b/figures/cmap-afmhot.png differ diff --git a/figures/cmap-autumn.png b/figures/cmap-autumn.png new file mode 100644 index 0000000..f4c7c01 Binary files /dev/null and b/figures/cmap-autumn.png differ diff --git a/figures/cmap-binary.png b/figures/cmap-binary.png new file mode 100644 index 0000000..b6e855b Binary files /dev/null and b/figures/cmap-binary.png differ diff --git a/figures/cmap-bone.png b/figures/cmap-bone.png new file mode 100644 index 0000000..eada6fd Binary files /dev/null and b/figures/cmap-bone.png differ diff --git a/figures/cmap-brg.png b/figures/cmap-brg.png new file mode 100644 index 0000000..2d0a376 Binary files /dev/null and b/figures/cmap-brg.png differ diff --git a/figures/cmap-bwr.png b/figures/cmap-bwr.png new file mode 100644 index 0000000..d3e2efa Binary files /dev/null and b/figures/cmap-bwr.png differ diff --git a/figures/cmap-cool.png b/figures/cmap-cool.png new file mode 100644 index 0000000..3d91af4 Binary files /dev/null and b/figures/cmap-cool.png differ diff --git a/figures/cmap-coolwarm.png b/figures/cmap-coolwarm.png new file mode 100644 index 0000000..9d5ee28 Binary files /dev/null and b/figures/cmap-coolwarm.png differ diff --git a/figures/cmap-copper.png b/figures/cmap-copper.png new file mode 100644 index 0000000..1a8b70b Binary files /dev/null and b/figures/cmap-copper.png differ diff --git a/figures/cmap-cubehelix.png b/figures/cmap-cubehelix.png new file mode 100644 index 0000000..9e953a6 Binary files /dev/null and b/figures/cmap-cubehelix.png differ diff --git a/figures/cmap-flag.png b/figures/cmap-flag.png new file mode 100644 index 0000000..9435b5a Binary files /dev/null and b/figures/cmap-flag.png differ diff --git a/figures/cmap-gist_earth.png b/figures/cmap-gist_earth.png new file mode 100644 index 0000000..dfeb80a Binary files /dev/null and b/figures/cmap-gist_earth.png differ diff --git a/figures/cmap-gist_gray.png b/figures/cmap-gist_gray.png new file mode 100644 index 0000000..bcebf1a Binary files /dev/null and b/figures/cmap-gist_gray.png differ diff --git a/figures/cmap-gist_heat.png b/figures/cmap-gist_heat.png new file mode 100644 index 0000000..733b42d Binary files /dev/null and b/figures/cmap-gist_heat.png differ diff --git a/figures/cmap-gist_ncar.png b/figures/cmap-gist_ncar.png new file mode 100644 index 0000000..16ff721 Binary files /dev/null and b/figures/cmap-gist_ncar.png differ diff --git a/figures/cmap-gist_rainbow.png b/figures/cmap-gist_rainbow.png new file mode 100644 index 0000000..bd69c1c Binary files /dev/null and b/figures/cmap-gist_rainbow.png differ diff --git a/figures/cmap-gist_stern.png b/figures/cmap-gist_stern.png new file mode 100644 index 0000000..2a977e5 Binary files /dev/null and b/figures/cmap-gist_stern.png differ diff --git a/figures/cmap-gist_yarg.png b/figures/cmap-gist_yarg.png new file mode 100644 index 0000000..b6e855b Binary files /dev/null and b/figures/cmap-gist_yarg.png differ diff --git a/figures/cmap-gnuplot.png b/figures/cmap-gnuplot.png new file mode 100644 index 0000000..0e2e728 Binary files /dev/null and b/figures/cmap-gnuplot.png differ diff --git a/figures/cmap-gnuplot2.png b/figures/cmap-gnuplot2.png new file mode 100644 index 0000000..31f08f9 Binary files /dev/null and b/figures/cmap-gnuplot2.png differ diff --git a/figures/cmap-gray.png b/figures/cmap-gray.png new file mode 100644 index 0000000..bcebf1a Binary files /dev/null and b/figures/cmap-gray.png differ diff --git a/figures/cmap-hot.png b/figures/cmap-hot.png new file mode 100644 index 0000000..8b61bd9 Binary files /dev/null and b/figures/cmap-hot.png differ diff --git a/figures/cmap-hsv.png b/figures/cmap-hsv.png new file mode 100644 index 0000000..07b4c64 Binary files /dev/null and b/figures/cmap-hsv.png differ diff --git a/figures/cmap-jet.png b/figures/cmap-jet.png new file mode 100644 index 0000000..050eeff Binary files /dev/null and b/figures/cmap-jet.png differ diff --git a/figures/cmap-ocean.png b/figures/cmap-ocean.png new file mode 100644 index 0000000..6c65130 Binary files /dev/null and b/figures/cmap-ocean.png differ diff --git a/figures/cmap-pink.png b/figures/cmap-pink.png new file mode 100644 index 0000000..75d302a Binary files /dev/null and b/figures/cmap-pink.png differ diff --git a/figures/cmap-prism.png b/figures/cmap-prism.png new file mode 100644 index 0000000..8a09df3 Binary files /dev/null and b/figures/cmap-prism.png differ diff --git a/figures/cmap-rainbow.png b/figures/cmap-rainbow.png new file mode 100644 index 0000000..ff5ca55 Binary files /dev/null and b/figures/cmap-rainbow.png differ diff --git a/figures/cmap-seismic.png b/figures/cmap-seismic.png new file mode 100644 index 0000000..3391d82 Binary files /dev/null and b/figures/cmap-seismic.png differ diff --git a/figures/cmap-spectral-2.png b/figures/cmap-spectral-2.png new file mode 100644 index 0000000..8b7d358 Binary files /dev/null and b/figures/cmap-spectral-2.png differ diff --git a/figures/cmap-spectral.png b/figures/cmap-spectral.png new file mode 100644 index 0000000..10d274c Binary files /dev/null and b/figures/cmap-spectral.png differ diff --git a/figures/cmap-spring.png b/figures/cmap-spring.png new file mode 100644 index 0000000..31064bb Binary files /dev/null and b/figures/cmap-spring.png differ diff --git a/figures/cmap-summer.png b/figures/cmap-summer.png new file mode 100644 index 0000000..b04badb Binary files /dev/null and b/figures/cmap-summer.png differ diff --git a/figures/cmap-terrain.png b/figures/cmap-terrain.png new file mode 100644 index 0000000..03033e5 Binary files /dev/null and b/figures/cmap-terrain.png differ diff --git a/figures/cmap-winter.png b/figures/cmap-winter.png new file mode 100644 index 0000000..4a98c8c Binary files /dev/null and b/figures/cmap-winter.png differ diff --git a/figures/color.png b/figures/color.png new file mode 100644 index 0000000..14c7e0f Binary files /dev/null and b/figures/color.png differ diff --git a/figures/contour.png b/figures/contour.png new file mode 100644 index 0000000..58fbf62 Binary files /dev/null and b/figures/contour.png differ diff --git a/figures/contour_ex.png b/figures/contour_ex.png new file mode 100644 index 0000000..28b8d55 Binary files /dev/null and b/figures/contour_ex.png differ diff --git a/figures/contourf.png b/figures/contourf.png new file mode 100644 index 0000000..35e94bb Binary files /dev/null and b/figures/contourf.png differ diff --git a/figures/dash_capstyle.png b/figures/dash_capstyle.png new file mode 100644 index 0000000..bc0006a Binary files /dev/null and b/figures/dash_capstyle.png differ diff --git a/figures/dash_joinstyle.png b/figures/dash_joinstyle.png new file mode 100644 index 0000000..b4629be Binary files /dev/null and b/figures/dash_joinstyle.png differ diff --git a/figures/date.png b/figures/date.png new file mode 100644 index 0000000..8ad837e Binary files /dev/null and b/figures/date.png differ diff --git a/figures/exercice_1.png b/figures/exercice_1.png new file mode 100644 index 0000000..2610e80 Binary files /dev/null and b/figures/exercice_1.png differ diff --git a/figures/exercice_10.png b/figures/exercice_10.png new file mode 100644 index 0000000..11d8576 Binary files /dev/null and b/figures/exercice_10.png differ diff --git a/figures/exercice_2.png b/figures/exercice_2.png new file mode 100644 index 0000000..2610e80 Binary files /dev/null and b/figures/exercice_2.png differ diff --git a/figures/exercice_3.png b/figures/exercice_3.png new file mode 100644 index 0000000..c302ea5 Binary files /dev/null and b/figures/exercice_3.png differ diff --git a/figures/exercice_4.png b/figures/exercice_4.png new file mode 100644 index 0000000..8fe34d0 Binary files /dev/null and b/figures/exercice_4.png differ diff --git a/figures/exercice_5.png b/figures/exercice_5.png new file mode 100644 index 0000000..4f1076f Binary files /dev/null and b/figures/exercice_5.png differ diff --git a/figures/exercice_6.png b/figures/exercice_6.png new file mode 100644 index 0000000..117e9d9 Binary files /dev/null and b/figures/exercice_6.png differ diff --git a/figures/exercice_7.png b/figures/exercice_7.png new file mode 100644 index 0000000..a177e65 Binary files /dev/null and b/figures/exercice_7.png differ diff --git a/figures/exercice_8.png b/figures/exercice_8.png new file mode 100644 index 0000000..f2e30a5 Binary files /dev/null and b/figures/exercice_8.png differ diff --git a/figures/exercice_9.png b/figures/exercice_9.png new file mode 100644 index 0000000..722eb8e Binary files /dev/null and b/figures/exercice_9.png differ diff --git a/figures/grid.png b/figures/grid.png new file mode 100644 index 0000000..a10b16d Binary files /dev/null and b/figures/grid.png differ diff --git a/figures/grid_ex.png b/figures/grid_ex.png new file mode 100644 index 0000000..1c59aae Binary files /dev/null and b/figures/grid_ex.png differ diff --git a/figures/gridspec.png b/figures/gridspec.png new file mode 100644 index 0000000..1378b15 Binary files /dev/null and b/figures/gridspec.png differ diff --git a/figures/hist.png b/figures/hist.png new file mode 100644 index 0000000..349b64b Binary files /dev/null and b/figures/hist.png differ diff --git a/figures/imshow.png b/figures/imshow.png new file mode 100644 index 0000000..10ec447 Binary files /dev/null and b/figures/imshow.png differ diff --git a/figures/imshow_ex.png b/figures/imshow_ex.png new file mode 100644 index 0000000..a690f5b Binary files /dev/null and b/figures/imshow_ex.png differ diff --git a/figures/legend.png b/figures/legend.png new file mode 100644 index 0000000..22f2a83 Binary files /dev/null and b/figures/legend.png differ diff --git a/figures/linestyle-*.png b/figures/linestyle-*.png new file mode 100644 index 0000000..0160547 Binary files /dev/null and b/figures/linestyle-*.png differ diff --git a/figures/linestyle-+.png b/figures/linestyle-+.png new file mode 100644 index 0000000..cdb1d4e Binary files /dev/null and b/figures/linestyle-+.png differ diff --git a/figures/linestyle-,.png b/figures/linestyle-,.png new file mode 100644 index 0000000..62da18d Binary files /dev/null and b/figures/linestyle-,.png differ diff --git a/figures/linestyle---.png b/figures/linestyle---.png new file mode 100644 index 0000000..2c9c90c Binary files /dev/null and b/figures/linestyle---.png differ diff --git a/figures/linestyle--..png b/figures/linestyle--..png new file mode 100644 index 0000000..63bb96f Binary files /dev/null and b/figures/linestyle--..png differ diff --git a/figures/linestyle--.png b/figures/linestyle--.png new file mode 100644 index 0000000..87eb2b2 Binary files /dev/null and b/figures/linestyle--.png differ diff --git a/figures/linestyle--dot.png b/figures/linestyle--dot.png new file mode 100644 index 0000000..35d76b1 Binary files /dev/null and b/figures/linestyle--dot.png differ diff --git a/figures/linestyle-..png b/figures/linestyle-..png new file mode 100644 index 0000000..4f44d1d Binary files /dev/null and b/figures/linestyle-..png differ diff --git a/figures/linestyle-1.png b/figures/linestyle-1.png new file mode 100644 index 0000000..f71a102 Binary files /dev/null and b/figures/linestyle-1.png differ diff --git a/figures/linestyle-2.png b/figures/linestyle-2.png new file mode 100644 index 0000000..78305a2 Binary files /dev/null and b/figures/linestyle-2.png differ diff --git a/figures/linestyle-3.png b/figures/linestyle-3.png new file mode 100644 index 0000000..9347326 Binary files /dev/null and b/figures/linestyle-3.png differ diff --git a/figures/linestyle-4.png b/figures/linestyle-4.png new file mode 100644 index 0000000..f6e222c Binary files /dev/null and b/figures/linestyle-4.png differ diff --git a/figures/linestyle-:.png b/figures/linestyle-:.png new file mode 100644 index 0000000..e53d2f3 Binary files /dev/null and b/figures/linestyle-:.png differ diff --git a/figures/linestyle-<.png b/figures/linestyle-<.png new file mode 100644 index 0000000..2d4ea01 Binary files /dev/null and b/figures/linestyle-<.png differ diff --git a/figures/linestyle->.png b/figures/linestyle->.png new file mode 100644 index 0000000..f615acf Binary files /dev/null and b/figures/linestyle->.png differ diff --git a/figures/linestyle-^.png b/figures/linestyle-^.png new file mode 100644 index 0000000..0ed71e8 Binary files /dev/null and b/figures/linestyle-^.png differ diff --git a/figures/linestyle-_.png b/figures/linestyle-_.png new file mode 100644 index 0000000..4054169 Binary files /dev/null and b/figures/linestyle-_.png differ diff --git a/figures/linestyle-d.png b/figures/linestyle-d.png new file mode 100644 index 0000000..fff7d47 Binary files /dev/null and b/figures/linestyle-d.png differ diff --git a/figures/linestyle-dd.png b/figures/linestyle-dd.png new file mode 100644 index 0000000..7966e9f Binary files /dev/null and b/figures/linestyle-dd.png differ diff --git a/figures/linestyle-dot.png b/figures/linestyle-dot.png new file mode 100644 index 0000000..8bb9af5 Binary files /dev/null and b/figures/linestyle-dot.png differ diff --git a/figures/linestyle-h.png b/figures/linestyle-h.png new file mode 100644 index 0000000..c43e06d Binary files /dev/null and b/figures/linestyle-h.png differ diff --git a/figures/linestyle-hh.png b/figures/linestyle-hh.png new file mode 100644 index 0000000..fe99402 Binary files /dev/null and b/figures/linestyle-hh.png differ diff --git a/figures/linestyle-o.png b/figures/linestyle-o.png new file mode 100644 index 0000000..43b6ce1 Binary files /dev/null and b/figures/linestyle-o.png differ diff --git a/figures/linestyle-p.png b/figures/linestyle-p.png new file mode 100644 index 0000000..6966355 Binary files /dev/null and b/figures/linestyle-p.png differ diff --git a/figures/linestyle-s.png b/figures/linestyle-s.png new file mode 100644 index 0000000..f0df658 Binary files /dev/null and b/figures/linestyle-s.png differ diff --git a/figures/linestyle-v.png b/figures/linestyle-v.png new file mode 100644 index 0000000..5232b50 Binary files /dev/null and b/figures/linestyle-v.png differ diff --git a/figures/linestyle-x.png b/figures/linestyle-x.png new file mode 100644 index 0000000..03a95cc Binary files /dev/null and b/figures/linestyle-x.png differ diff --git a/figures/linestyle-|.png b/figures/linestyle-|.png new file mode 100644 index 0000000..3a8c06e Binary files /dev/null and b/figures/linestyle-|.png differ diff --git a/figures/linewidth.png b/figures/linewidth.png new file mode 100644 index 0000000..cdadc78 Binary files /dev/null and b/figures/linewidth.png differ diff --git a/figures/loglog.png b/figures/loglog.png new file mode 100644 index 0000000..851e44f Binary files /dev/null and b/figures/loglog.png differ diff --git a/figures/marker-*.png b/figures/marker-*.png new file mode 100644 index 0000000..a8efd79 Binary files /dev/null and b/figures/marker-*.png differ diff --git a/figures/marker-+.png b/figures/marker-+.png new file mode 100644 index 0000000..9ce9ad3 Binary files /dev/null and b/figures/marker-+.png differ diff --git a/figures/marker-,.png b/figures/marker-,.png new file mode 100644 index 0000000..88c81a6 Binary files /dev/null and b/figures/marker-,.png differ diff --git a/figures/marker-..png b/figures/marker-..png new file mode 100644 index 0000000..4f44d1d Binary files /dev/null and b/figures/marker-..png differ diff --git a/figures/marker-0.png b/figures/marker-0.png new file mode 100644 index 0000000..3ea99c3 Binary files /dev/null and b/figures/marker-0.png differ diff --git a/figures/marker-1.png b/figures/marker-1.png new file mode 100644 index 0000000..4aa3b0b Binary files /dev/null and b/figures/marker-1.png differ diff --git a/figures/marker-2.png b/figures/marker-2.png new file mode 100644 index 0000000..963c010 Binary files /dev/null and b/figures/marker-2.png differ diff --git a/figures/marker-3.png b/figures/marker-3.png new file mode 100644 index 0000000..6425e21 Binary files /dev/null and b/figures/marker-3.png differ diff --git a/figures/marker-4.png b/figures/marker-4.png new file mode 100644 index 0000000..0b1458d Binary files /dev/null and b/figures/marker-4.png differ diff --git a/figures/marker-5.png b/figures/marker-5.png new file mode 100644 index 0000000..8fd4177 Binary files /dev/null and b/figures/marker-5.png differ diff --git a/figures/marker-6.png b/figures/marker-6.png new file mode 100644 index 0000000..3fcc02b Binary files /dev/null and b/figures/marker-6.png differ diff --git a/figures/marker-7.png b/figures/marker-7.png new file mode 100644 index 0000000..b8bf56f Binary files /dev/null and b/figures/marker-7.png differ diff --git a/figures/marker-8.png b/figures/marker-8.png new file mode 100644 index 0000000..1680e73 Binary files /dev/null and b/figures/marker-8.png differ diff --git a/figures/marker-<.png b/figures/marker-<.png new file mode 100644 index 0000000..ae583bc Binary files /dev/null and b/figures/marker-<.png differ diff --git a/figures/marker->.png b/figures/marker->.png new file mode 100644 index 0000000..8e0e93c Binary files /dev/null and b/figures/marker->.png differ diff --git a/figures/marker-^.png b/figures/marker-^.png new file mode 100644 index 0000000..6035470 Binary files /dev/null and b/figures/marker-^.png differ diff --git a/figures/marker-_.png b/figures/marker-_.png new file mode 100644 index 0000000..6b1b0e3 Binary files /dev/null and b/figures/marker-_.png differ diff --git a/figures/marker-d.png b/figures/marker-d.png new file mode 100644 index 0000000..bbf09e9 Binary files /dev/null and b/figures/marker-d.png differ diff --git a/figures/marker-dd.png b/figures/marker-dd.png new file mode 100644 index 0000000..20792bd Binary files /dev/null and b/figures/marker-dd.png differ diff --git a/figures/marker-dot.png b/figures/marker-dot.png new file mode 100644 index 0000000..cf02d89 Binary files /dev/null and b/figures/marker-dot.png differ diff --git a/figures/marker-h.png b/figures/marker-h.png new file mode 100644 index 0000000..4e9f0eb Binary files /dev/null and b/figures/marker-h.png differ diff --git a/figures/marker-hh.png b/figures/marker-hh.png new file mode 100644 index 0000000..4097821 Binary files /dev/null and b/figures/marker-hh.png differ diff --git a/figures/marker-i0.png b/figures/marker-i0.png new file mode 100644 index 0000000..ae58abd Binary files /dev/null and b/figures/marker-i0.png differ diff --git a/figures/marker-i1.png b/figures/marker-i1.png new file mode 100644 index 0000000..77e82ff Binary files /dev/null and b/figures/marker-i1.png differ diff --git a/figures/marker-i2.png b/figures/marker-i2.png new file mode 100644 index 0000000..9d05eef Binary files /dev/null and b/figures/marker-i2.png differ diff --git a/figures/marker-i3.png b/figures/marker-i3.png new file mode 100644 index 0000000..9cc6178 Binary files /dev/null and b/figures/marker-i3.png differ diff --git a/figures/marker-i4.png b/figures/marker-i4.png new file mode 100644 index 0000000..05498d7 Binary files /dev/null and b/figures/marker-i4.png differ diff --git a/figures/marker-i5.png b/figures/marker-i5.png new file mode 100644 index 0000000..623cbc3 Binary files /dev/null and b/figures/marker-i5.png differ diff --git a/figures/marker-i6.png b/figures/marker-i6.png new file mode 100644 index 0000000..5007c80 Binary files /dev/null and b/figures/marker-i6.png differ diff --git a/figures/marker-i7.png b/figures/marker-i7.png new file mode 100644 index 0000000..0b38418 Binary files /dev/null and b/figures/marker-i7.png differ diff --git a/figures/marker-latex.png b/figures/marker-latex.png new file mode 100644 index 0000000..94ea06d Binary files /dev/null and b/figures/marker-latex.png differ diff --git a/figures/marker-o.png b/figures/marker-o.png new file mode 100644 index 0000000..dfbf6d6 Binary files /dev/null and b/figures/marker-o.png differ diff --git a/figures/marker-p.png b/figures/marker-p.png new file mode 100644 index 0000000..39144d4 Binary files /dev/null and b/figures/marker-p.png differ diff --git a/figures/marker-s.png b/figures/marker-s.png new file mode 100644 index 0000000..777e1d9 Binary files /dev/null and b/figures/marker-s.png differ diff --git a/figures/marker-v.png b/figures/marker-v.png new file mode 100644 index 0000000..a3a014b Binary files /dev/null and b/figures/marker-v.png differ diff --git a/figures/marker-x.png b/figures/marker-x.png new file mode 100644 index 0000000..d9931b4 Binary files /dev/null and b/figures/marker-x.png differ diff --git a/figures/marker-|.png b/figures/marker-|.png new file mode 100644 index 0000000..36fd448 Binary files /dev/null and b/figures/marker-|.png differ diff --git a/figures/mec.png b/figures/mec.png new file mode 100644 index 0000000..8d4901f Binary files /dev/null and b/figures/mec.png differ diff --git a/figures/mew.png b/figures/mew.png new file mode 100644 index 0000000..f02b68e Binary files /dev/null and b/figures/mew.png differ diff --git a/figures/mfc.png b/figures/mfc.png new file mode 100644 index 0000000..8343429 Binary files /dev/null and b/figures/mfc.png differ diff --git a/figures/ms.png b/figures/ms.png new file mode 100644 index 0000000..36ebd74 Binary files /dev/null and b/figures/ms.png differ diff --git a/figures/multiplot.png b/figures/multiplot.png new file mode 100644 index 0000000..dc6c6f3 Binary files /dev/null and b/figures/multiplot.png differ diff --git a/figures/multiplot_ex.png b/figures/multiplot_ex.png new file mode 100644 index 0000000..7727e02 Binary files /dev/null and b/figures/multiplot_ex.png differ diff --git a/figures/pie.png b/figures/pie.png new file mode 100644 index 0000000..6c4c0e6 Binary files /dev/null and b/figures/pie.png differ diff --git a/figures/pie_ex.png b/figures/pie_ex.png new file mode 100644 index 0000000..8d22229 Binary files /dev/null and b/figures/pie_ex.png differ diff --git a/figures/plot.png b/figures/plot.png new file mode 100644 index 0000000..b29ee67 Binary files /dev/null and b/figures/plot.png differ diff --git a/figures/plot3d.png b/figures/plot3d.png new file mode 100644 index 0000000..4eae582 Binary files /dev/null and b/figures/plot3d.png differ diff --git a/figures/plot3d_ex.png b/figures/plot3d_ex.png new file mode 100644 index 0000000..a057423 Binary files /dev/null and b/figures/plot3d_ex.png differ diff --git a/figures/plot_ex.png b/figures/plot_ex.png new file mode 100644 index 0000000..a631fe1 Binary files /dev/null and b/figures/plot_ex.png differ diff --git a/figures/polar.png b/figures/polar.png new file mode 100644 index 0000000..483114b Binary files /dev/null and b/figures/polar.png differ diff --git a/figures/polar_ex.png b/figures/polar_ex.png new file mode 100644 index 0000000..97895ce Binary files /dev/null and b/figures/polar_ex.png differ diff --git a/figures/quiver.png b/figures/quiver.png new file mode 100644 index 0000000..b710329 Binary files /dev/null and b/figures/quiver.png differ diff --git a/figures/quiver_ex.png b/figures/quiver_ex.png new file mode 100644 index 0000000..8b4f986 Binary files /dev/null and b/figures/quiver_ex.png differ diff --git a/figures/scatter.png b/figures/scatter.png new file mode 100644 index 0000000..3e50920 Binary files /dev/null and b/figures/scatter.png differ diff --git a/figures/scatter_ex.png b/figures/scatter_ex.png new file mode 100644 index 0000000..6a3e659 Binary files /dev/null and b/figures/scatter_ex.png differ diff --git a/figures/simple.png b/figures/simple.png new file mode 100644 index 0000000..2dcab92 Binary files /dev/null and b/figures/simple.png differ diff --git a/figures/solid_capstyle.png b/figures/solid_capstyle.png new file mode 100644 index 0000000..9b141f9 Binary files /dev/null and b/figures/solid_capstyle.png differ diff --git a/figures/solid_joinstyle.png b/figures/solid_joinstyle.png new file mode 100644 index 0000000..62783eb Binary files /dev/null and b/figures/solid_joinstyle.png differ diff --git a/figures/spy.png b/figures/spy.png new file mode 100644 index 0000000..1790904 Binary files /dev/null and b/figures/spy.png differ diff --git a/figures/stem.png b/figures/stem.png new file mode 100644 index 0000000..637976d Binary files /dev/null and b/figures/stem.png differ diff --git a/figures/subplot-grid.png b/figures/subplot-grid.png new file mode 100644 index 0000000..4d46e34 Binary files /dev/null and b/figures/subplot-grid.png differ diff --git a/figures/subplot-horizontal.png b/figures/subplot-horizontal.png new file mode 100644 index 0000000..5685164 Binary files /dev/null and b/figures/subplot-horizontal.png differ diff --git a/figures/subplot-vertical.png b/figures/subplot-vertical.png new file mode 100644 index 0000000..272c1a5 Binary files /dev/null and b/figures/subplot-vertical.png differ diff --git a/figures/subplots_four.png b/figures/subplots_four.png new file mode 100644 index 0000000..d087273 Binary files /dev/null and b/figures/subplots_four.png differ diff --git a/figures/subplots_horizontal.png b/figures/subplots_horizontal.png new file mode 100644 index 0000000..fde5b26 Binary files /dev/null and b/figures/subplots_horizontal.png differ diff --git a/figures/subplots_vertical.png b/figures/subplots_vertical.png new file mode 100644 index 0000000..d8d36d9 Binary files /dev/null and b/figures/subplots_vertical.png differ diff --git a/figures/text.png b/figures/text.png new file mode 100644 index 0000000..427d0d1 Binary files /dev/null and b/figures/text.png differ diff --git a/figures/text_ex.png b/figures/text_ex.png new file mode 100644 index 0000000..10ac8bf Binary files /dev/null and b/figures/text_ex.png differ diff --git a/figures/ticks-AutoLocator.png b/figures/ticks-AutoLocator.png new file mode 100644 index 0000000..0b79747 Binary files /dev/null and b/figures/ticks-AutoLocator.png differ diff --git a/figures/ticks-FixedLocator.png b/figures/ticks-FixedLocator.png new file mode 100644 index 0000000..36e2aae Binary files /dev/null and b/figures/ticks-FixedLocator.png differ diff --git a/figures/ticks-IndexLocator.png b/figures/ticks-IndexLocator.png new file mode 100644 index 0000000..84438ff Binary files /dev/null and b/figures/ticks-IndexLocator.png differ diff --git a/figures/ticks-LinearLocator.png b/figures/ticks-LinearLocator.png new file mode 100644 index 0000000..ebc2968 Binary files /dev/null and b/figures/ticks-LinearLocator.png differ diff --git a/figures/ticks-LogLocator.png b/figures/ticks-LogLocator.png new file mode 100644 index 0000000..1de4021 Binary files /dev/null and b/figures/ticks-LogLocator.png differ diff --git a/figures/ticks-MinuteLocator.png b/figures/ticks-MinuteLocator.png new file mode 100644 index 0000000..0b79747 Binary files /dev/null and b/figures/ticks-MinuteLocator.png differ diff --git a/figures/ticks-MultipleLocator.png b/figures/ticks-MultipleLocator.png new file mode 100644 index 0000000..8066481 Binary files /dev/null and b/figures/ticks-MultipleLocator.png differ diff --git a/figures/ticks-NullLocator.png b/figures/ticks-NullLocator.png new file mode 100644 index 0000000..79b3bef Binary files /dev/null and b/figures/ticks-NullLocator.png differ diff --git a/figures/ticks.png b/figures/ticks.png new file mode 100644 index 0000000..9e4fca2 Binary files /dev/null and b/figures/ticks.png differ diff --git a/index.rst b/index.rst new file mode 100644 index 0000000..def98f8 --- /dev/null +++ b/index.rst @@ -0,0 +1,1731 @@ +=================================== +Matplotlib tutorial +=================================== + +------------------------------------------------ +Nicolas P. Rougier - Euroscipy 2012 - Prace 2013 +------------------------------------------------ + +.. contents:: + :local: + :depth: 2 + +This tutorial is based on Mike Müller's `tutorial +`_ available +from the `scipy lecture notes `_. + +Sources are available `here `_. Figures are in the `figures +`_ directory and all scripts are located in the `scripts `_ +directory. Github repository is `here +`_ + +All code and material is licensed under a Creative Commons Attribution 3.0 +United States License (CC-by) http://creativecommons.org/licenses/by/3.0/us + +Many thanks to **Bill Wing** and **Christoph Deil** for review and corrections. + + +Introduction +============ + +matplotlib is probably the single most used Python package for 2D-graphics. It +provides both a very quick way to visualize data from Python and +publication-quality figures in many formats. We are going to explore +matplotlib in interactive mode covering most common cases. + +IPython and the pylab mode +-------------------------- + +`IPython `_ is an enhanced interactive Python shell that +has lots of interesting features including named inputs and outputs, access to +shell commands, improved debugging and many more. When we start it with the +command line argument -pylab (--pylab since IPython version 0.12), it allows +interactive matplotlib sessions that have Matlab/Mathematica-like functionality. + +pylab +----- + +pylab provides a procedural interface to the matplotlib object-oriented +plotting library. It is modeled closely after Matlab(TM). Therefore, the +majority of plotting commands in pylab have Matlab(TM) analogs with similar +arguments. Important commands are explained with interactive examples. + + + + +Simple plot +=========== + +In this section, we want to draw the cosine and sine functions on the same +plot. Starting from the default settings, we'll enrich the figure step by step +to make it nicer. + +First step is to get the data for the sine and cosine functions: + +:: + + from pylab import * + + X = np.linspace(-np.pi, np.pi, 256,endpoint=True) + C,S = np.cos(X), np.sin(X) + + +X is now a numpy array with 256 values ranging from -π to +π (included). C is +the cosine (256 values) and S is the sine (256 values). + +To run the example, you can type them in an IPython interactive session + + $ ipython --pylab + +This brings us to the IPython prompt: + +:: + + IPython 0.13 -- An enhanced Interactive Python. + ? -> Introduction to IPython's features. + %magic -> Information about IPython's 'magic' % functions. + help -> Python's own help system. + object? -> Details about 'object'. ?object also works, ?? prints more. + + Welcome to pylab, a matplotlib-based Python environment. + For more information, type 'help(pylab)'. + + +or you can download each of the examples and run it using regular python:: + + $ python exercice_1.py + +You can get source for each step by clicking on the corresponding figure. + + +Using defaults +-------------- + +.. admonition:: Documentation + + * `plot tutorial `_ + * `plot() command `_ + +.. image:: figures/exercice_1.png + :align: right + :target: scripts/exercice_1.py + +Matplotlib comes with a set of default settings that allow customizing all +kinds of properties. You can control the defaults of almost every property in +matplotlib: figure size and dpi, line width, color and style, axes, axis and +grid properties, text and font properties and so on. While matplotlib defaults +are rather good in most cases, you may want to modify some properties for +specific cases. + + +:: + + from pylab import * + + X = np.linspace(-np.pi, np.pi, 256,endpoint=True) + C,S = np.cos(X), np.sin(X) + + plot(X,C) + plot(X,S) + + show() + + + + + +Instantiating defaults +---------------------- + +.. admonition:: Documentation + + * `Customizing matplotlib `_ + +.. image:: figures/exercice_2.png + :align: right + :target: scripts/exercice_2.py + + +In the script below, we've instantiated (and commented) all the figure settings +that influence the appearance of the plot. The settings have been explicitly +set to their default values, but now you can interactively play with the values +to explore their affect (see `Line properties`_ and `Line styles`_ below). + +:: + + # Import everything from matplotlib (numpy is accessible via 'np' alias) + from pylab import * + + # Create a new figure of size 8x6 points, using 80 dots per inch + figure(figsize=(8,6), dpi=80) + + # Create a new subplot from a grid of 1x1 + subplot(1,1,1) + + X = np.linspace(-np.pi, np.pi, 256,endpoint=True) + C,S = np.cos(X), np.sin(X) + + # Plot cosine using blue color with a continuous line of width 1 (pixels) + plot(X, C, color="blue", linewidth=1.0, linestyle="-") + + # Plot sine using green color with a continuous line of width 1 (pixels) + plot(X, S, color="green", linewidth=1.0, linestyle="-") + + # Set x limits + xlim(-4.0,4.0) + + # Set x ticks + xticks(np.linspace(-4,4,9,endpoint=True)) + + # Set y limits + ylim(-1.0,1.0) + + # Set y ticks + yticks(np.linspace(-1,1,5,endpoint=True)) + + # Save figure using 72 dots per inch + # savefig("exercice_2.png",dpi=72) + + # Show result on screen + show() + + +Changing colors and line widths +-------------------------------- + +.. admonition:: Documentation + + * `Controlling line properties `_ + * `Line API `_ + +.. image:: figures/exercice_3.png + :align: right + :target: scripts/exercice_3.py + +First step, we want to have the cosine in blue and the sine in red and a +slighty thicker line for both of them. We'll also slightly alter the figure +size to make it more horizontal. + + +:: + + ... + figure(figsize=(10,6), dpi=80) + plot(X, C, color="blue", linewidth=2.5, linestyle="-") + plot(X, S, color="red", linewidth=2.5, linestyle="-") + ... + + + +Setting limits +-------------- + +.. admonition:: Documentation + + * `xlim() command `_ + * `ylim() command `_ + + +.. image:: figures/exercice_4.png + :align: right + :target: scripts/exercice_4.py + +Current limits of the figure are a bit too tight and we want to make some space +in order to clearly see all data points. + +:: + + ... + xlim(X.min()*1.1, X.max()*1.1) + ylim(C.min()*1.1, C.max()*1.1) + ... + + + +Setting ticks +------------- + +.. admonition:: Documentation + + * `xticks() command `_ + * `yticks() command `_ + * `Tick container `_ + * `Tick locating and formatting `_ + + +.. image:: figures/exercice_5.png + :align: right + :target: scripts/exercice_5.py + +Current ticks are not ideal because they do not show the interesting values +(+/-π,+/-π/2) for sine and cosine. We'll change them such that they show only +these values. + +:: + + ... + xticks( [-np.pi, -np.pi/2, 0, np.pi/2, np.pi]) + yticks([-1, 0, +1]) + ... + + + +Setting tick labels +------------------- + +.. admonition:: Documentation + + * `Working with text `_ + * `xticks() command `_ + * `yticks() command `_ + * `set_xticklabels() `_ + * `set_yticklabels() `_ + +.. image:: figures/exercice_6.png + :align: right + :target: scripts/exercice_6.py + +Ticks are now properly placed but their label is not very explicit. We could +guess that 3.142 is π but it would be better to make it explicit. When we set +tick values, we can also provide a corresponding label in the second argument +list. Note that we'll use latex to allow for nice rendering of the label. + + +:: + + ... + xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + + yticks([-1, 0, +1], + [r'$-1$', r'$0$', r'$+1$']) + ... + + + +Moving spines +------------- + +.. admonition:: Documentation + + * `Spines `_ + * `Axis container `_ + * `Transformations tutorial `_ + +.. image:: figures/exercice_7.png + :align: right + :target: scripts/exercice_7.py + +Spines are the lines connecting the axis tick marks and noting the boundaries +of the data area. They can be placed at arbitrary positions and until now, they +were on the border of the axis. We'll change that since we want to have them in +the middle. Since there are four of them (top/bottom/left/right), we'll discard +the top and right by setting their color to none and we'll move the bottom and +left ones to coordinate 0 in data space coordinates. + +:: + + ... + ax = gca() + 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)) + ... + + + +Adding a legend +--------------- + + +.. admonition:: Documentation + + * `Legend guide `_ + * `legend() command `_ + * `Legend API `_ + +.. image:: figures/exercice_8.png + :align: right + :target: scripts/exercice_8.py + +Let's add a legend in the upper left corner. This only requires adding the +keyword argument label (that will be used in the legend box) to the plot +commands. + + +:: + + ... + plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine") + plot(X, S, color="red", linewidth=2.5, linestyle="-", label="sine") + + legend(loc='upper left') + ... + + + +Annotate some points +-------------------- + +.. admonition:: Documentation + + * `Annotating axis `_ + * `annotate() command `_ + +.. image:: figures/exercice_9.png + :align: right + :target: scripts/exercice_9.py + +Let's annotate some interesting points using the annotate command. We chose the +2π/3 value and we want to annotate both the sine and the cosine. We'll first +draw a marker on the curve as well as a straight dotted line. Then, we'll use +the annotate command to display some text with an arrow. + + +:: + + ... + + t = 2*np.pi/3 + plot([t,t],[0,np.cos(t)], color ='blue', linewidth=2.5, linestyle="--") + scatter([t,],[np.cos(t),], 50, color ='blue') + + annotate(r'$\sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$', + xy=(t, np.sin(t)), xycoords='data', + xytext=(+10, +30), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + + plot([t,t],[0,np.sin(t)], color ='red', linewidth=2.5, linestyle="--") + scatter([t,],[np.sin(t),], 50, color ='red') + + annotate(r'$\cos(\frac{2\pi}{3})=-\frac{1}{2}$', + xy=(t, np.cos(t)), xycoords='data', + xytext=(-90, -50), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + ... + + + +Devil is in the details +------------------------ + +.. admonition:: Documentation + + * `Artists `_ + * `BBox `_ + +.. image:: figures/exercice_10.png + :align: right + :target: scripts/exercice_10.py + +The tick labels are now hardly visible because of the blue and red lines. We can +make them bigger and we can also adjust their properties such that they'll be +rendered on a semi-transparent white background. This will allow us to see both +the data and the labels. + + +:: + + ... + for label in ax.get_xticklabels() + ax.get_yticklabels(): + label.set_fontsize(16) + label.set_bbox(dict(facecolor='white', edgecolor='None', alpha=0.65 )) + ... + + + + +Figures, Subplots, Axes and Ticks +================================= + +So far we have used implicit figure and axes creation. This is handy for fast +plots. We can have more control over the display using figure, subplot, and +axes explicitly. A figure in matplotlib means the whole window in the user +interface. Within this figure there can be subplots. While subplot positions +the plots in a regular grid, axes allows free placement within the figure. Both +can be useful depending on your intention. We've already worked with figures +and subplots without explicitly calling them. When we call plot, matplotlib +calls gca() to get the current axes and gca in turn calls gcf() to get the +current figure. If there is none it calls figure() to make one, strictly +speaking, to make a subplot(111). Let's look at the details. + +Figures +------- + +A figure is the windows in the GUI that has "Figure #" as title. Figures +are numbered starting from 1 as opposed to the normal Python way starting +from 0. This is clearly MATLAB-style. There are several parameters that +determine what the figure looks like: + +============== ======================= ============================================ +Argument Default Description +============== ======================= ============================================ +num 1 number of figure +figsize figure.figsize figure size in in inches (width, height) +dpi figure.dpi resolution in dots per inch +facecolor figure.facecolor color of the drawing background +edgecolor figure.edgecolor color of edge around the drawing background +frameon True draw figure frame or not +============== ======================= ============================================ + +The defaults can be specified in the resource file and will be used most of the +time. Only the number of the figure is frequently changed. + +When you work with the GUI you can close a figure by clicking on the x in the +upper right corner. But you can close a figure programmatically by calling +close. Depending on the argument it closes (1) the current figure (no +argument), (2) a specific figure (figure number or figure instance as +argument), or (3) all figures (all as argument). + +As with other objects, you can set figure properties also setp or with the +set_something methods. + + +Subplots +-------- + +With subplot you can arrange plots in a regular grid. You need to specify the +number of rows and columns and the number of the plot. Note that the `gridspec +`_ command is a more +powerful alternative. + +.. image:: figures/subplot-horizontal.png + :target: scripts/subplot-horizontal.py +.. image:: figures/subplot-vertical.png + :target: scripts/subplot-vertical.py +.. image:: figures/subplot-grid.png + :target: scripts/subplot-grid.py +.. image:: figures/gridspec.png + :target: scripts/gridspec.py + + + +Axes +---- + +Axes are very similar to subplots but allow placement of plots at any location +in the figure. So if we want to put a smaller plot inside a bigger one we do +so with axes. + +.. image:: figures/axes.png + :target: scripts/axes.py +.. image:: figures/axes-2.png + :target: scripts/axes-2.py + + +Ticks +----- + +Well formatted ticks are an important part of publishing-ready +figures. Matplotlib provides a totally configurable system for ticks. There are +tick locators to specify where ticks should appear and tick formatters to give +ticks the appearance you want. Major and minor ticks can be located and +formatted independently from each other. Per default minor ticks are not shown, +i.e. there is only an empty list for them because it is as NullLocator (see +below). + +Tick Locators +............. + +There are several locators for different kind of requirements: + + +.. list-table:: + :widths: 20 70 + :header-rows: 1 + + * - Class + - Description + + + * - ``NullLocator`` + - No ticks. + + .. image:: figures/ticks-NullLocator.png + + * - ``IndexLocator`` + - Place a tick on every multiple of some base number of points plotted. + + .. image:: figures/ticks-IndexLocator.png + + * - ``FixedLocator`` + - Tick locations are fixed. + + .. image:: figures/ticks-FixedLocator.png + + * - ``LinearLocator`` + - Determine the tick locations. + + .. image:: figures/ticks-LinearLocator.png + + * - ``MultipleLocator`` + - Set a tick on every integer that is multiple of some base. + + .. image:: figures/ticks-MultipleLocator.png + + * - ``AutoLocator`` + - Select no more than n intervals at nice locations. + + .. image:: figures/ticks-AutoLocator.png + + * - ``LogLocator`` + - Determine the tick locations for log axes. + + .. image:: figures/ticks-LogLocator.png + +All of these locators derive from the base class matplotlib.ticker.Locator. +You can make your own locator deriving from it. Handling dates as ticks can be +especially tricky. Therefore, matplotlib provides special locators in +matplotlib.dates. + + + + +Other Types of Plots +==================== + +.. image:: figures/plot.png + :target: `Regular Plots`_ + +.. image:: figures/scatter.png + :target: `Scatter Plots`_ + +.. image:: figures/bar.png + :target: `Bar Plots`_ + +.. image:: figures/contour.png + :target: `Contour Plots`_ + +.. image:: figures/imshow.png + :target: `Imshow`_ + +.. image:: figures/quiver.png + :target: `Quiver Plots`_ + +.. image:: figures/pie.png + :target: `Pie Charts`_ + +.. image:: figures/grid.png + :target: `Grids`_ + +.. image:: figures/multiplot.png + :target: `Multi Plots`_ + +.. image:: figures/polar.png + :target: `Polar Axis`_ + +.. image:: figures/plot3d.png + :target: `3D Plots`_ + +.. image:: figures/text.png + :target: `Text`_ + + +Regular Plots +------------- + +.. image:: figures/plot_ex.png + :align: right + :target: scripts/plot_ex.py + +.. admonition:: Hints + + You need to use the `fill_between + `_ + command. + +Starting from the code below, try to reproduce the graphic on the right taking +care of filled areas:: + + from pylab import * + + n = 256 + X = np.linspace(-np.pi,np.pi,n,endpoint=True) + Y = np.sin(2*X) + + plot (X, Y+1, color='blue', alpha=1.00) + plot (X, Y-1, color='blue', alpha=1.00) + show() + +Click on figure for solution. + + + +Scatter Plots +------------- + +.. image:: figures/scatter_ex.png + :align: right + :target: scripts/scatter_ex.py + +.. admonition:: Hints + + Color is given by angle of (X,Y). + + +Starting from the code below, try to reproduce the graphic on the right taking +care of marker size, color and transparency. + +:: + + from pylab import * + + n = 1024 + X = np.random.normal(0,1,n) + Y = np.random.normal(0,1,n) + + scatter(X,Y) + show() + +Click on figure for solution. + + + + +Bar Plots +--------- + +.. image:: figures/bar_ex.png + :align: right + :target: scripts/bar_ex.py + +.. admonition:: Hints + + You need to take care of text alignment. + + +Starting from the code below, try to reproduce the graphic on the right by +adding labels for red bars. + +:: + + from pylab import * + + n = 12 + X = np.arange(n) + Y1 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) + Y2 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) + + bar(X, +Y1, facecolor='#9999ff', edgecolor='white') + bar(X, -Y2, facecolor='#ff9999', edgecolor='white') + + for x,y in zip(X,Y1): + text(x+0.4, y+0.05, '%.2f' % y, ha='center', va= 'bottom') + + ylim(-1.25,+1.25) + show() + +Click on figure for solution. + + +Contour Plots +------------- + +.. image:: figures/contour_ex.png + :align: right + :target: scripts/contour_ex.py + +.. admonition:: Hints + + You need to use the `clabel + `_ + command. + +Starting from the code below, try to reproduce the graphic on the right taking +care of the colormap (see `Colormaps`_ below). + +:: + + from pylab import * + + def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + + n = 256 + x = np.linspace(-3,3,n) + y = np.linspace(-3,3,n) + X,Y = np.meshgrid(x,y) + + contourf(X, Y, f(X,Y), 8, alpha=.75, cmap='jet') + C = contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5) + show() + +Click on figure for solution. + + + +Imshow +------ + +.. image:: figures/imshow_ex.png + :align: right + :target: scripts/imshow_ex.py + +.. admonition:: Hints + + You need to take care of the ``origin`` of the image in the imshow command and + use a `colorbar + `_ + + +Starting from the code below, try to reproduce the graphic on the right taking +care of colormap, image interpolation and origin. + +:: + + from pylab import * + + def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + + n = 10 + x = np.linspace(-3,3,4*n) + y = np.linspace(-3,3,3*n) + X,Y = np.meshgrid(x,y) + imshow(f(X,Y)), show() + +Click on figure for solution. + + +Pie Charts +---------- + +.. image:: figures/pie_ex.png + :align: right + :target: scripts/pie_ex.py + +.. admonition:: Hints + + You need to modify Z. + +Starting from the code below, try to reproduce the graphic on the right taking +care of colors and slices size. + +:: + + from pylab import * + + n = 20 + Z = np.random.uniform(0,1,n) + pie(Z), show() + +Click on figure for solution. + + + +Quiver Plots +------------ + +.. image:: figures/quiver_ex.png + :align: right + :target: scripts/quiver_ex.py + +.. admonition:: Hints + + You need to draw arrows twice. + +Starting from the code above, try to reproduce the graphic on the right taking +care of colors and orientations. + +:: + + from pylab import * + + n = 8 + X,Y = np.mgrid[0:n,0:n] + quiver(X,Y), show() + +Click on figure for solution. + + + +Grids +----- + +.. image:: figures/grid_ex.png + :align: right + :target: scripts/grid_ex.py + + +Starting from the code below, try to reproduce the graphic on the right taking +care of line styles. + +:: + + from pylab import * + + axes = gca() + axes.set_xlim(0,4) + axes.set_ylim(0,3) + axes.set_xticklabels([]) + axes.set_yticklabels([]) + + show() + +Click on figure for solution. + + +Multi Plots +----------- + +.. image:: figures/multiplot_ex.png + :align: right + :target: scripts/multiplot_ex.py + +.. admonition:: Hints + + You can use several subplots with different partition. + + +Starting from the code below, try to reproduce the graphic on the right. + +:: + + from pylab import * + + subplot(2,2,1) + subplot(2,2,3) + subplot(2,2,4) + + show() + +Click on figure for solution. + + +Polar Axis +---------- + +.. image:: figures/polar_ex.png + :align: right + :target: scripts/polar_ex.py + +.. admonition:: Hints + + You only need to modify the ``axes`` line + + +Starting from the code below, try to reproduce the graphic on the right. + +:: + + from pylab import * + + axes([0,0,1,1]) + + N = 20 + theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) + radii = 10*np.random.rand(N) + width = np.pi/4*np.random.rand(N) + bars = bar(theta, radii, width=width, bottom=0.0) + + for r,bar in zip(radii, bars): + bar.set_facecolor( cm.jet(r/10.)) + bar.set_alpha(0.5) + + show() + +Click on figure for solution. + + +3D Plots +-------- + +.. image:: figures/plot3d_ex.png + :align: right + :target: scripts/plot3d_ex.py + +.. admonition:: Hints + + You need to use `contourf + `_ + + +Starting from the code below, try to reproduce the graphic on the right. + +:: + + from pylab import * + from mpl_toolkits.mplot3d import Axes3D + + fig = figure() + ax = Axes3D(fig) + X = np.arange(-4, 4, 0.25) + Y = np.arange(-4, 4, 0.25) + X, Y = np.meshgrid(X, Y) + R = np.sqrt(X**2 + Y**2) + Z = np.sin(R) + + ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot') + + show() + +Click on figure for solution. + + + +Text +---- + +.. image:: figures/text_ex.png + :align: right + :target: scripts/text_ex.py + +.. admonition:: Hints + + Have a look at the `matplotlib logo + `_. + +Try to do the same from scratch ! + +Click on figure for solution. + + +Beyond this tutorial +==================== + +Matplotlib benefits from extensive documentation as well as a large +community of users and developpers. Here are some links of interest: + +Tutorials +--------- + +* `Pyplot tutorial `_ + + - Introduction + - Controlling line properties + - Working with multiple figures and axes + - Working with text + - + +* `Image tutorial `_ + + - Startup commands + - Importing image data into Numpy arrays + - Plotting numpy arrays as images + - + +* `Text tutorial `_ + + - Text introduction + - Basic text commands + - Text properties and layout + - Writing mathematical expressions + - Text rendering With LaTeX + - Annotating text + - + +* `Artist tutorial `_ + + - Introduction + - Customizing your objects + - Object containers + - Figure container + - Axes container + - Axis containers + - Tick containers + - + +* `Path tutorial `_ + + - Introduction + - Bézier example + - Compound paths + - + +* `Transforms tutorial `_ + + - Introduction + - Data coordinates + - Axes coordinates + - Blended transformations + - Using offset transforms to create a shadow effect + - The transformation pipeline + - + + + +Matplotlib documentation +------------------------ + +* `User guide `_ + +* `FAQ `_ + + - Installation + - Usage + - How-To + - Troubleshooting + - Environment Variables + - + +* `Screenshots `_ + + +Code documentation +------------------ + +The code is fairly well documented and you can quickly access a specific +command from within a python session: + +:: + + >>> from pylab import * + >>> help(plot) + Help on function plot in module matplotlib.pyplot: + + plot(*args, **kwargs) + Plot lines and/or markers to the + :class:`~matplotlib.axes.Axes`. *args* is a variable length + argument, allowing for multiple *x*, *y* pairs with an + optional format string. For example, each of the following is + legal:: + + plot(x, y) # plot x and y using default line style and color + plot(x, y, 'bo') # plot x and y using blue circle markers + plot(y) # plot y using x as index array 0..N-1 + plot(y, 'r+') # ditto, but with red plusses + + If *x* and/or *y* is 2-dimensional, then the corresponding columns + will be plotted. + ... + +Galleries +--------- + +The `matplotlib gallery `_ is +also incredibly useful when you search how to render a given graphic. Each +example comes with its source. + +A smaller gallery is also available `here `_. + + +Mailing lists +-------------- + +Finally, there is a `user mailing list +`_ where you can +ask for help and a `developers mailing list +`_ that is more +technical. + + + +Quick references +================ + +Here is a set of tables that show main properties and styles. + +Line properties +---------------- + +.. list-table:: + :widths: 20 30 50 + :header-rows: 1 + + * - Property + - Description + - Appearance + + * - alpha (or a) + - alpha transparency on 0-1 scale + - .. image:: figures/alpha.png + + * - antialiased + - True or False - use antialised rendering + - .. image:: figures/aliased.png + .. image:: figures/antialiased.png + + * - color (or c) + - matplotlib color arg + - .. image:: figures/color.png + + * - linestyle (or ls) + - see `Line properties`_ + - + + * - linewidth (or lw) + - float, the line width in points + - .. image:: figures/linewidth.png + + * - solid_capstyle + - Cap style for solid lines + - .. image:: figures/solid_capstyle.png + + * - solid_joinstyle + - Join style for solid lines + - .. image:: figures/solid_joinstyle.png + + * - dash_capstyle + - Cap style for dashes + - .. image:: figures/dash_capstyle.png + + * - dash_joinstyle + - Join style for dashes + - .. image:: figures/dash_joinstyle.png + + * - marker + - see `Markers`_ + - + + * - markeredgewidth (mew) + - line width around the marker symbol + - .. image:: figures/mew.png + + * - markeredgecolor (mec) + - edge color if a marker is used + - .. image:: figures/mec.png + + * - markerfacecolor (mfc) + - face color if a marker is used + - .. image:: figures/mfc.png + + * - markersize (ms) + - size of the marker in points + - .. image:: figures/ms.png + + + +Line styles +----------- + +.. list-table:: + :widths: 15 30 50 + :header-rows: 1 + + * - Symbol + - Description + - Appearance + + * - ``-`` + - solid line + - .. image:: figures/linestyle--.png + + * - ``--`` + - dashed line + - .. image:: figures/linestyle---.png + + * - ``-.`` + - dash-dot line + - .. image:: figures/linestyle--dot.png + + * - ``:`` + - dotted line + - .. image:: figures/linestyle-:.png + + * - ``.`` + - points + - .. image:: figures/linestyle-dot.png + + * - ``,`` + - pixels + - .. image:: figures/linestyle-,.png + + * - ``o`` + - circle + - .. image:: figures/linestyle-o.png + + * - ``^`` + - triangle up + - .. image:: figures/linestyle-^.png + + * - ``v`` + - triangle down + - .. image:: figures/linestyle-v.png + + * - ``<`` + - triangle left + - .. image:: figures/linestyle-<.png + + * - ``>`` + - triangle right + - .. image:: figures/linestyle->.png + + * - ``s`` + - square + - .. image:: figures/linestyle-s.png + + * - ``+`` + - plus + - .. image:: figures/linestyle-+.png + + * - ``x`` + - cross + - .. image:: figures/linestyle-x.png + + * - ``D`` + - diamond + - .. image:: figures/linestyle-dd.png + + * - ``d`` + - thin diamond + - .. image:: figures/linestyle-d.png + + * - ``1`` + - tripod down + - .. image:: figures/linestyle-1.png + + * - ``2`` + - tripod up + - .. image:: figures/linestyle-2.png + + * - ``3`` + - tripod left + - .. image:: figures/linestyle-3.png + + * - ``4`` + - tripod right + - .. image:: figures/linestyle-4.png + + * - ``h`` + - hexagon + - .. image:: figures/linestyle-h.png + + * - ``H`` + - rotated hexagon + - .. image:: figures/linestyle-hh.png + + * - ``p`` + - pentagon + - .. image:: figures/linestyle-p.png + + * - ``|`` + - vertical line + - .. image:: figures/linestyle-|.png + + * - ``_`` + - horizontal line + - .. image:: figures/linestyle-_.png + + +Markers +------- + + +.. list-table:: + :widths: 15 30 50 + :header-rows: 1 + + * - Symbol + - Description + - Appearance + + * - 0 + - tick left + - .. image:: figures/marker-i0.png + + * - 1 + - tick right + - .. image:: figures/marker-i1.png + + * - 2 + - tick up + - .. image:: figures/marker-i2.png + + * - 3 + - tick down + - .. image:: figures/marker-i3.png + + * - 4 + - caret left + - .. image:: figures/marker-i4.png + + * - 5 + - caret right + - .. image:: figures/marker-i5.png + + * - 6 + - caret up + - .. image:: figures/marker-i6.png + + * - 7 + - caret down + - .. image:: figures/marker-i7.png + + * - ``o`` + - circle + - .. image:: figures/marker-o.png + + * - ``D`` + - diamond + - .. image:: figures/marker-dd.png + + * - ``h`` + - hexagon 1 + - .. image:: figures/marker-h.png + + * - ``H`` + - hexagon 2 + - .. image:: figures/marker-hh.png + + * - ``_`` + - horizontal line + - .. image:: figures/marker-_.png + + * - ``1`` + - tripod down + - .. image:: figures/marker-1.png + + * - ``2`` + - tripod up + - .. image:: figures/marker-2.png + + * - ``3`` + - tripod left + - .. image:: figures/marker-3.png + + * - ``4`` + - tripod right + - .. image:: figures/marker-4.png + + * - ``8`` + - octagon + - .. image:: figures/marker-8.png + + * - ``p`` + - pentagon + - .. image:: figures/marker-p.png + + * - ``^`` + - triangle up + - .. image:: figures/marker-^.png + + * - ``v`` + - triangle down + - .. image:: figures/marker-v.png + + * - ``<`` + - triangle left + - .. image:: figures/marker-<.png + + * - ``>`` + - triangle right + - .. image:: figures/marker->.png + + * - ``d`` + - thin diamond + - .. image:: figures/marker-d.png + + * - ``,`` + - pixel + - .. image:: figures/marker-,.png + + * - ``+`` + - plus + - .. image:: figures/marker-+.png + + * - ``.`` + - point + - .. image:: figures/marker-dot.png + + * - ``s`` + - square + - .. image:: figures/marker-s.png + + * - ``*`` + - star + - .. image:: figures/marker-*.png + + * - ``|`` + - vertical line + - .. image:: figures/marker-|.png + + * - ``x`` + - cross + - .. image:: figures/marker-x.png + + * - ``r'$\sqrt{2}$'`` + - any latex expression + - .. image:: figures/marker-latex.png + + + + +Colormaps +--------- + +All colormaps can be reversed by appending ``_r``. For instance, ``gray_r`` is +the reverse of ``gray``. + +If you want to know more about colormaps, checks `Documenting the matplotlib +colormaps `_. + + +Base +.... + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + * - autumn + - .. image:: figures/cmap-autumn.png + + * - bone + - .. image:: figures/cmap-bone.png + + * - cool + - .. image:: figures/cmap-cool.png + + * - copper + - .. image:: figures/cmap-copper.png + + * - flag + - .. image:: figures/cmap-flag.png + + * - gray + - .. image:: figures/cmap-gray.png + + * - hot + - .. image:: figures/cmap-hot.png + + * - hsv + - .. image:: figures/cmap-hsv.png + + * - jet + - .. image:: figures/cmap-jet.png + + * - pink + - .. image:: figures/cmap-pink.png + + * - prism + - .. image:: figures/cmap-prism.png + + * - spectral + - .. image:: figures/cmap-spectral.png + + * - spring + - .. image:: figures/cmap-spring.png + + * - summer + - .. image:: figures/cmap-summer.png + + * - winter + - .. image:: figures/cmap-winter.png + + +GIST +.... + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + * - gist_earth + - .. image:: figures/cmap-gist_earth.png + + * - gist_gray + - .. image:: figures/cmap-gist_gray.png + + * - gist_heat + - .. image:: figures/cmap-gist_heat.png + + * - gist_ncar + - .. image:: figures/cmap-gist_ncar.png + + * - gist_rainbow + - .. image:: figures/cmap-gist_rainbow.png + + * - gist_stern + - .. image:: figures/cmap-gist_stern.png + + * - gist_yarg + - .. image:: figures/cmap-gist_yarg.png + + +Sequential +.......... + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + * - BrBG + - .. image:: figures/cmap-BrBG.png + + * - PiYG + - .. image:: figures/cmap-PiYG.png + + * - PRGn + - .. image:: figures/cmap-PRGn.png + + * - PuOr + - .. image:: figures/cmap-PuOr.png + + * - RdBu + - .. image:: figures/cmap-RdBu.png + + * - RdGy + - .. image:: figures/cmap-RdGy.png + + * - RdYlBu + - .. image:: figures/cmap-RdYlBu.png + + * - RdYlGn + - .. image:: figures/cmap-RdYlGn.png + + * - Spectral + - .. image:: figures/cmap-spectral-2.png + + + +Diverging +......... + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + * - Blues + - .. image:: figures/cmap-Blues.png + + * - BuGn + - .. image:: figures/cmap-BuGn.png + + * - BuPu + - .. image:: figures/cmap-BuPu.png + + * - GnBu + - .. image:: figures/cmap-GnBu.png + + * - Greens + - .. image:: figures/cmap-Greens.png + + * - Greys + - .. image:: figures/cmap-Greys.png + + * - Oranges + - .. image:: figures/cmap-Oranges.png + + * - OrRd + - .. image:: figures/cmap-OrRd.png + + * - PuBu + - .. image:: figures/cmap-PuBu.png + + * - PuBuGn + - .. image:: figures/cmap-PuBuGn.png + + * - PuRd + - .. image:: figures/cmap-PuRd.png + + * - Purples + - .. image:: figures/cmap-Purples.png + + * - RdPu + - .. image:: figures/cmap-RdPu.png + + * - Reds + - .. image:: figures/cmap-Reds.png + + * - YlGn + - .. image:: figures/cmap-YlGn.png + + * - YlGnBu + - .. image:: figures/cmap-YlGnBu.png + + * - YlOrBr + - .. image:: figures/cmap-YlOrBr.png + + * - YlOrRd + - .. image:: figures/cmap-YlOrRd.png + + +Qualitative +........... + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + * - Accent + - .. image:: figures/cmap-Accent.png + + * - Dark2 + - .. image:: figures/cmap-Dark2.png + + * - Paired + - .. image:: figures/cmap-Paired.png + + * - Pastel1 + - .. image:: figures/cmap-Pastel1.png + + * - Pastel2 + - .. image:: figures/cmap-Pastel2.png + + * - Set1 + - .. image:: figures/cmap-Set1.png + + * - Set2 + - .. image:: figures/cmap-Set2.png + + * - Set3 + - .. image:: figures/cmap-Set3.png + + + +Miscellaneous +............. + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + + * - Name + - Appearance + + + * - afmhot + - .. image:: figures/cmap-afmhot.png + + + * - binary + - .. image:: figures/cmap-binary.png + + * - brg + - .. image:: figures/cmap-brg.png + + * - bwr + - .. image:: figures/cmap-bwr.png + + * - coolwarm + - .. image:: figures/cmap-coolwarm.png + + * - CMRmap + - .. image:: figures/cmap-CMRmap.png + + * - cubehelix + - .. image:: figures/cmap-cubehelix.png + + * - gnuplot + - .. image:: figures/cmap-gnuplot.png + + * - gnuplot2 + - .. image:: figures/cmap-gnuplot2.png + + * - ocean + - .. image:: figures/cmap-ocean.png + + * - rainbow + - .. image:: figures/cmap-rainbow.png + + * - seismic + - .. image:: figures/cmap-seismic.png + + * - terrain + - .. image:: figures/cmap-terrain.png diff --git a/reset.css b/reset.css new file mode 100644 index 0000000..46d5856 --- /dev/null +++ b/reset.css @@ -0,0 +1,33 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/scripts/.DS_Store b/scripts/.DS_Store new file mode 100644 index 0000000..5570389 Binary files /dev/null and b/scripts/.DS_Store differ diff --git a/scripts/aliased.py b/scripts/aliased.py new file mode 100644 index 0000000..fe2c5c3 --- /dev/null +++ b/scripts/aliased.py @@ -0,0 +1,16 @@ +from pylab import * + +size = 128,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +rcParams['text.antialiased'] = False +text(0.5,0.5,"Aliased",ha='center',va='center') + +plt.xlim(0,1),plt.ylim(0,1), +plt.xticks([]),plt.yticks([]) + +savefig('../figures/aliased.png', dpi=dpi) diff --git a/scripts/alpha.py b/scripts/alpha.py new file mode 100644 index 0000000..1dc7403 --- /dev/null +++ b/scripts/alpha.py @@ -0,0 +1,15 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0.1,1,.8], frameon=False) + +for i in range(1,11): + plt.axvline(i, linewidth=1, color='blue',alpha=.25+.75*i/10.) + +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/alpha.png', dpi=dpi) diff --git a/scripts/antialiased.py b/scripts/antialiased.py new file mode 100644 index 0000000..3b42c28 --- /dev/null +++ b/scripts/antialiased.py @@ -0,0 +1,16 @@ +from pylab import * + +size = 128,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +rcParams['text.antialiased'] = True +text(0.5,0.5,"Anti-aliased",ha='center',va='center') + +plt.xlim(0,1),plt.ylim(0,1), +plt.xticks([]),plt.yticks([]) + +savefig('../figures/antialiased.png', dpi=dpi) diff --git a/scripts/axes-2.py b/scripts/axes-2.py new file mode 100644 index 0000000..3ec03c7 --- /dev/null +++ b/scripts/axes-2.py @@ -0,0 +1,20 @@ +from pylab import * + +axes([0.1,0.1,.5,.5]) +xticks([]), yticks([]) +text(0.1,0.1, 'axes([0.1,0.1,.8,.8])',ha='left',va='center',size=16,alpha=.5) + +axes([0.2,0.2,.5,.5]) +xticks([]), yticks([]) +text(0.1,0.1, 'axes([0.2,0.2,.5,.5])',ha='left',va='center',size=16,alpha=.5) + +axes([0.3,0.3,.5,.5]) +xticks([]), yticks([]) +text(0.1,0.1, 'axes([0.3,0.3,.5,.5])',ha='left',va='center',size=16,alpha=.5) + +axes([0.4,0.4,.5,.5]) +xticks([]), yticks([]) +text(0.1,0.1, 'axes([0.4,0.4,.5,.5])',ha='left',va='center',size=16,alpha=.5) + +# plt.savefig("../figures/axes-2.png",dpi=64) +show() diff --git a/scripts/axes.py b/scripts/axes.py new file mode 100644 index 0000000..2cf495a --- /dev/null +++ b/scripts/axes.py @@ -0,0 +1,12 @@ +from pylab import * + +axes([0.1,0.1,.8,.8]) +xticks([]), yticks([]) +text(0.6,0.6, 'axes([0.1,0.1,.8,.8])',ha='center',va='center',size=20,alpha=.5) + +axes([0.2,0.2,.3,.3]) +xticks([]), yticks([]) +text(0.5,0.5, 'axes([0.2,0.2,.3,.3])',ha='center',va='center',size=16,alpha=.5) + +plt.savefig("../figures/axes.png",dpi=64) +show() diff --git a/scripts/bad.py b/scripts/bad.py new file mode 100644 index 0000000..6f88eac --- /dev/null +++ b/scripts/bad.py @@ -0,0 +1,14 @@ +import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + +fig = plt.figure(figsize=(5,4),dpi=72) +axes = fig.add_axes([0.01, 0.01, .98, 0.98]) +X = np.linspace(0,2,200,endpoint=True) +Y = np.sin(2*np.pi*X) +plt.plot (X, Y, lw=.25, c='k') +plt.xticks(np.arange(0.0, 2.0, 0.1)) +plt.yticks(np.arange(-1.0,1.0, 0.1)) +plt.grid() +fig.savefig('../figures/bad.png', dpi=72) diff --git a/scripts/bar.py b/scripts/bar.py new file mode 100644 index 0000000..8fb0177 --- /dev/null +++ b/scripts/bar.py @@ -0,0 +1,28 @@ +from pylab import * + +n = 16 +X = np.arange(n) +Y1 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) +Y2 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) +bar(X, +Y1, facecolor='#9999ff', edgecolor='white') +bar(X, -Y2, facecolor='#ff9999', edgecolor='white') +xlim(-.5,n), xticks([]) +ylim(-1,+1), yticks([]) + +text(-0.05, 1.05, " Bar Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +text(-0.05, .975, " Make a bar plot with rectangles ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +savefig('../figures/bar.png', dpi=64) + diff --git a/scripts/bar_ex.py b/scripts/bar_ex.py new file mode 100644 index 0000000..5f24fa6 --- /dev/null +++ b/scripts/bar_ex.py @@ -0,0 +1,22 @@ +from pylab import * + +n = 12 +X = np.arange(n) +Y1 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) +Y2 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n) + +axes([0.025,0.025,0.95,0.95]) +bar(X, +Y1, facecolor='#9999ff', edgecolor='white') +bar(X, -Y2, facecolor='#ff9999', edgecolor='white') + +for x,y in zip(X,Y1): + text(x+0.4, y+0.05, '%.2f' % y, ha='center', va= 'bottom') + +for x,y in zip(X,Y2): + text(x+0.4, -y-0.05, '%.2f' % y, ha='center', va= 'top') + +xlim(-.5,n), xticks([]) +ylim(-1.25,+1.25), yticks([]) + +# savefig('../figures/bar_ex.png', dpi=48) +show() diff --git a/scripts/boxplot.py b/scripts/boxplot.py new file mode 100644 index 0000000..c05bf61 --- /dev/null +++ b/scripts/boxplot.py @@ -0,0 +1,36 @@ +import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + +fig = plt.figure(figsize=(8,5),dpi=72) +fig.patch.set_alpha(0.0) +axes = plt.subplot(111) + +n = 5 +Z = np.zeros((n,4)) +X = np.linspace(0,2,n,endpoint=True) +Y = np.random.random((n,4)) +plt.boxplot(Y) + +#plt.xlim(-0.2,4.2) +#plt.ylim(-1.2,1.2) +plt.xticks([]), plt.yticks([]) + +plt.text(-0.05, 1.05, " Box Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = axes.transAxes) + +plt.text(-0.05, .95, " Make a box and whisker plot ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = axes.transAxes) + +plt.savefig('../figures/boxplot.png', dpi=64) +plt.show() diff --git a/scripts/color.py b/scripts/color.py new file mode 100644 index 0000000..38a84d8 --- /dev/null +++ b/scripts/color.py @@ -0,0 +1,14 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0.1,1,.8], frameon=False) + +for i in range(1,11): + plot( [i,i], [0,1], lw=1.5 ) +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/color.png', dpi=dpi) diff --git a/scripts/colormaps.py b/scripts/colormaps.py new file mode 100644 index 0000000..c2ee0d5 --- /dev/null +++ b/scripts/colormaps.py @@ -0,0 +1,42 @@ +from pylab import * + +def colormap(cmap,filename): + n = 512 + Z = np.linspace(0,1,n,endpoint=True).reshape((1,n)) + size = 512,16 + dpi = 72.0 + figsize= size[0]/float(dpi),size[1]/float(dpi) + fig = plt.figure(figsize=figsize, dpi=dpi) + fig.patch.set_alpha(0) + axes([0.,0.,1.,1.], frameon=False) + xticks([]), yticks([]) + imshow(Z,aspect='auto',cmap=cmap,origin="lower") + savefig( "../figures/cmap-%s.png" % filename, dpi=dpi ) + + + +cmaps = [m for m in cm.datad if not m.endswith("_r")] +cmaps.sort() + +#print """ +#.. list-table:: +# :widths: 10 30 50 +# :header-rows: 1 +# +# * - Name +# - Description +# - Appearance +# +#""" + +for i in range(len(cmaps)): + name = cmaps[i] + filename = name + if name == 'Spectral': + filename = 'spectral-2' + colormap(name,filename) + #print " * - %s" % name + #print " - " + #print " - .. image:: figures/cmap-%s.png" % filename + #print + diff --git a/scripts/contour.py b/scripts/contour.py new file mode 100644 index 0000000..ed5bfd5 --- /dev/null +++ b/scripts/contour.py @@ -0,0 +1,31 @@ +from pylab import * + +def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + +n = 256 +x = np.linspace(-3,3,n) +y = np.linspace(-3,3,n) +X,Y = np.meshgrid(x,y) + +contourf(X, Y, f(X,Y), 8, alpha=.75, cmap=cm.hot) +C = contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5) +clabel(C, inline=1, fontsize=10) +xticks([]), yticks([]) + +text(-0.05, 1.05, " Contour Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +text(-0.05, .975, " Draw contour lines and filled contours ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +savefig('../figures/contour.png', dpi=64) + diff --git a/scripts/contour_ex.py b/scripts/contour_ex.py new file mode 100644 index 0000000..4641ec4 --- /dev/null +++ b/scripts/contour_ex.py @@ -0,0 +1,18 @@ +from pylab import * + +def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + +n = 256 +x = np.linspace(-3,3,n) +y = np.linspace(-3,3,n) +X,Y = np.meshgrid(x,y) + +axes([0.025,0.025,0.95,0.95]) + +contourf(X, Y, f(X,Y), 8, alpha=.75, cmap=cm.hot) +C = contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5) +clabel(C, inline=1, fontsize=10) + +xticks([]), yticks([]) +# savefig('../figures/contour_ex.png',dpi=48) +show() diff --git a/scripts/dash_capstyle.py b/scripts/dash_capstyle.py new file mode 100644 index 0000000..7411fc4 --- /dev/null +++ b/scripts/dash_capstyle.py @@ -0,0 +1,20 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +plot(np.arange(4), np.ones(4), color="blue", dashes=[15,15], linewidth=8, dash_capstyle = 'butt') + +plot(5+np.arange(4), np.ones(4), color="blue", dashes=[15,15], linewidth=8, dash_capstyle = 'round') + +plot(10+np.arange(4), np.ones(4), color="blue", dashes=[15,15], linewidth=8, dash_capstyle = 'projecting') + +xlim(0,14) +xticks([]),yticks([]) + +savefig('../figures/dash_capstyle.png', dpi=dpi) +#show() diff --git a/scripts/dash_joinstyle.py b/scripts/dash_joinstyle.py new file mode 100644 index 0000000..8f2f682 --- /dev/null +++ b/scripts/dash_joinstyle.py @@ -0,0 +1,18 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +plot(np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'miter') +plot(4+np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'bevel') +plot(8+np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'round') + +xlim(0,12), ylim(-1,2) +xticks([]),yticks([]) + +savefig('../figures/dash_joinstyle.png', dpi=dpi) +#show() diff --git a/scripts/exercice_1.py b/scripts/exercice_1.py new file mode 100644 index 0000000..515de7a --- /dev/null +++ b/scripts/exercice_1.py @@ -0,0 +1,9 @@ +from pylab import * + +n = 256 +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) +plot(X,C),plot(X,S) + +#savefig("../figures/exercice_1.png",dpi=72) +show() diff --git a/scripts/exercice_10.py b/scripts/exercice_10.py new file mode 100644 index 0000000..f160d53 --- /dev/null +++ b/scripts/exercice_10.py @@ -0,0 +1,52 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine") +plot(X, S, color="red", linewidth=2.5, linestyle="-", label="sine") + +ax = gca() +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)) + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, +1], + [r'$-1$', r'$+1$']) + + +legend(loc='upper left') + +t = 2*np.pi/3 +plot([t,t],[0,np.cos(t)], + color ='blue', linewidth=1.5, linestyle="--") +scatter([t,],[np.cos(t),], 50, color ='blue') +annotate(r'$\sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$', xy=(t, np.sin(t)), xycoords='data', + xytext=(+10, +30), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + +plot([t,t],[0,np.sin(t)], + color ='red', linewidth=1.5, linestyle="--") +scatter([t,],[np.sin(t),], 50, color ='red') +annotate(r'$\cos(\frac{2\pi}{3})=-\frac{1}{2}$', xy=(t, np.cos(t)), xycoords='data', + xytext=(-90, -50), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + +for label in ax.get_xticklabels() + ax.get_yticklabels(): + label.set_fontsize(16) + label.set_bbox(dict(facecolor='white', edgecolor='None', alpha=0.65 )) + + +# savefig("../figures/exercice_10.png",dpi=72) +show() diff --git a/scripts/exercice_2.py b/scripts/exercice_2.py new file mode 100644 index 0000000..96e4081 --- /dev/null +++ b/scripts/exercice_2.py @@ -0,0 +1,35 @@ +# Import everything from matplotlib (numpy is accessible via 'np' alias) +from pylab import * + +# Create a new figure of size 8x6 points, using 100 dots per inch +figure(figsize=(8,6), dpi=80) + +# Create a new subplot from a grid of 1x1 +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +# Plot cosine using blue color with a continuous line of width 1 (pixels) +plot(X, C, color="blue", linewidth=1.0, linestyle="-") + +# Plot sine using green color with a continuous line of width 1 (pixels) +plot(X, S, color="green", linewidth=1.0, linestyle="-") + +# Set x limits +xlim(-4.0,4.0) + +# Set x ticks +xticks(np.linspace(-4,4,9,endpoint=True)) + +# Set y limits +ylim(-1.0,1.0) + +# Set y ticks +yticks(np.linspace(-1,1,5,endpoint=True)) + +# Save figure using 72 dots per inch +# savefig("../figures/exercice_2.png",dpi=72) + +# Show result on screen +show() diff --git a/scripts/exercice_3.py b/scripts/exercice_3.py new file mode 100644 index 0000000..f62cb36 --- /dev/null +++ b/scripts/exercice_3.py @@ -0,0 +1,19 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +xlim(-4.0,4.0) +xticks(np.linspace(-4,4,9,endpoint=True)) + +ylim(-1.0,1.0) +yticks(np.linspace(-1,1,5,endpoint=True)) + +#savefig("../figures/exercice_3.png",dpi=72) +show() diff --git a/scripts/exercice_4-bis.py b/scripts/exercice_4-bis.py new file mode 100644 index 0000000..fb88ec3 --- /dev/null +++ b/scripts/exercice_4-bis.py @@ -0,0 +1,17 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X+.1, C, color="blue", linewidth=2.5, linestyle="-",alpha=.15) +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +xlim(X.min()*1.1, X.max()*1.1) +ylim(C.min()*1.1,C.max()*1.1) + +# savefig("../figures/exercice_4.png",dpi=72) +show() diff --git a/scripts/exercice_4.py b/scripts/exercice_4.py new file mode 100644 index 0000000..8ed68ac --- /dev/null +++ b/scripts/exercice_4.py @@ -0,0 +1,16 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +xlim(X.min()*1.1, X.max()*1.1) +ylim(C.min()*1.1,C.max()*1.1) + +# savefig("../figures/exercice_4.png",dpi=72) +show() diff --git a/scripts/exercice_5.py b/scripts/exercice_5.py new file mode 100644 index 0000000..69d605c --- /dev/null +++ b/scripts/exercice_5.py @@ -0,0 +1,19 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi]) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, 0, +1]) + +# savefig("../figures/exercice_5.png",dpi=72) +show() diff --git a/scripts/exercice_6.py b/scripts/exercice_6.py new file mode 100644 index 0000000..7fefc24 --- /dev/null +++ b/scripts/exercice_6.py @@ -0,0 +1,21 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, 0, +1], + [r'$-1$', r'$0$', r'$+1$']) + +# savefig("../figures/exercice_6.png",dpi=72) +show() diff --git a/scripts/exercice_7.py b/scripts/exercice_7.py new file mode 100644 index 0000000..39a3b23 --- /dev/null +++ b/scripts/exercice_7.py @@ -0,0 +1,29 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-") +plot(X, S, color="red", linewidth=2.5, linestyle="-") + +ax = gca() +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)) + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, 0, +1], + [r'$-1$', r'$0$', r'$+1$']) + +# savefig("../figures/exercice_7.png",dpi=72) +show() diff --git a/scripts/exercice_8.py b/scripts/exercice_8.py new file mode 100644 index 0000000..79c5fbf --- /dev/null +++ b/scripts/exercice_8.py @@ -0,0 +1,32 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine") +plot(X, S, color="red", linewidth=2.5, linestyle="-", label="sine") + +ax = gca() +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)) + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, +1], + [r'$-1$', r'$+1$']) + + +legend(loc='upper left') + +# savefig("../figures/exercice_8.png",dpi=72) +show() diff --git a/scripts/exercice_9.py b/scripts/exercice_9.py new file mode 100644 index 0000000..7dd0f30 --- /dev/null +++ b/scripts/exercice_9.py @@ -0,0 +1,46 @@ +from pylab import * + +figure(figsize=(8,5), dpi=80) +subplot(111) + +X = np.linspace(-np.pi, np.pi, 256,endpoint=True) +C,S = np.cos(X), np.sin(X) + +plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine") +plot(X, S, color="red", linewidth=2.5, linestyle="-", label="sine") + +ax = gca() +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)) + +xlim(X.min()*1.1, X.max()*1.1) +xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], + [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) + +ylim(C.min()*1.1,C.max()*1.1) +yticks([-1, +1], + [r'$-1$', r'$+1$']) + +t = 2*np.pi/3 +plot([t,t],[0,np.cos(t)], + color ='blue', linewidth=1.5, linestyle="--") +scatter([t,],[np.cos(t),], 50, color ='blue') +annotate(r'$\sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$', xy=(t, np.sin(t)), xycoords='data', + xytext=(+10, +30), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + +plot([t,t],[0,np.sin(t)], + color ='red', linewidth=1.5, linestyle="--") +scatter([t,],[np.sin(t),], 50, color ='red') +annotate(r'$\cos(\frac{2\pi}{3})=-\frac{1}{2}$', xy=(t, np.cos(t)), xycoords='data', + xytext=(-90, -50), textcoords='offset points', fontsize=16, + arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) + +legend(loc='upper left') + +# savefig("../figures/exercice_9.png",dpi=72) +show() diff --git a/scripts/good.py b/scripts/good.py new file mode 100644 index 0000000..6e544de --- /dev/null +++ b/scripts/good.py @@ -0,0 +1,14 @@ +import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + +fig = plt.figure(figsize=(5,4),dpi=72) +axes = fig.add_axes([0.01, 0.01, .98, 0.98]) #, frameon=False) +X = np.linspace(0,2,200,endpoint=True) +Y = np.sin(2*np.pi*X) +plt.plot (X, Y, lw=2) +plt.ylim(-1.1,1.1) +plt.grid() +fig.savefig('../figures/good.png', dpi=72) + diff --git a/scripts/grid.py b/scripts/grid.py new file mode 100644 index 0000000..be08006 --- /dev/null +++ b/scripts/grid.py @@ -0,0 +1,37 @@ +import numpy as np +import matplotlib +import matplotlib.pyplot as plt +from matplotlib.ticker import MultipleLocator + +fig = plt.figure(figsize=(8,6), dpi=72, facecolor="white") +axes = plt.subplot(111) +axes.set_xlim(0,4) +axes.set_ylim(0,3) + +axes.xaxis.set_major_locator(MultipleLocator(1.0)) +axes.xaxis.set_minor_locator(MultipleLocator(0.1)) +axes.yaxis.set_major_locator(MultipleLocator(1.0)) +axes.yaxis.set_minor_locator(MultipleLocator(0.1)) +axes.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75') +axes.grid(which='minor', axis='x', linewidth=0.25, linestyle='-', color='0.75') +axes.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75') +axes.grid(which='minor', axis='y', linewidth=0.25, linestyle='-', color='0.75') +axes.set_xticklabels([]) +axes.set_yticklabels([]) + +plt.text(-0.05, 1.05, " Grid \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = axes.transAxes) + +plt.text(-0.05, .975, " Draw ticks and grid ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = axes.transAxes) + +plt.savefig('../figures/grid.png', dpi=64) diff --git a/scripts/grid_ex.py b/scripts/grid_ex.py new file mode 100644 index 0000000..cc8f626 --- /dev/null +++ b/scripts/grid_ex.py @@ -0,0 +1,19 @@ +from pylab import * + +ax = axes([0.025,0.025,0.95,0.95]) + +ax.set_xlim(0,4) +ax.set_ylim(0,3) +ax.xaxis.set_major_locator(MultipleLocator(1.0)) +ax.xaxis.set_minor_locator(MultipleLocator(0.1)) +ax.yaxis.set_major_locator(MultipleLocator(1.0)) +ax.yaxis.set_minor_locator(MultipleLocator(0.1)) +ax.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75') +ax.grid(which='minor', axis='x', linewidth=0.25, linestyle='-', color='0.75') +ax.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75') +ax.grid(which='minor', axis='y', linewidth=0.25, linestyle='-', color='0.75') +ax.set_xticklabels([]) +ax.set_yticklabels([]) + +# savefig('../figures/grid_ex.png',dpi=48) +show() diff --git a/scripts/gridspec.py b/scripts/gridspec.py new file mode 100644 index 0000000..25bcbd6 --- /dev/null +++ b/scripts/gridspec.py @@ -0,0 +1,27 @@ +from pylab import * +import matplotlib.gridspec as gridspec + +G = gridspec.GridSpec(3, 3) + +axes_1 = subplot(G[0, :]) +xticks([]), yticks([]) +text(0.5,0.5, 'Axes 1',ha='center',va='center',size=24,alpha=.5) + +axes_2 = subplot(G[1,:-1]) +xticks([]), yticks([]) +text(0.5,0.5, 'Axes 2',ha='center',va='center',size=24,alpha=.5) + +axes_3 = subplot(G[1:, -1]) +xticks([]), yticks([]) +text(0.5,0.5, 'Axes 3',ha='center',va='center',size=24,alpha=.5) + +axes_4 = subplot(G[-1,0]) +xticks([]), yticks([]) +text(0.5,0.5, 'Axes 4',ha='center',va='center',size=24,alpha=.5) + +axes_5 = subplot(G[-1,-2]) +xticks([]), yticks([]) +text(0.5,0.5, 'Axes 5',ha='center',va='center',size=24,alpha=.5) + +#plt.savefig('../figures/gridspec.png', dpi=64) +show() diff --git a/scripts/imshow.py b/scripts/imshow.py new file mode 100644 index 0000000..a094c76 --- /dev/null +++ b/scripts/imshow.py @@ -0,0 +1,29 @@ +from pylab import * + +def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + +n = 10 +x = np.linspace(-3,3,8*n) +y = np.linspace(-3,3,6*n) +X,Y = np.meshgrid(x,y) +Z = f(X,Y) +imshow(Z,interpolation='nearest',cmap='bone', origin='lower') +xticks([]), yticks([]) + +plt.text(-0.05, 1.05, " Imshow \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +plt.text(-0.05, .975, " Display an image to current axes ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/imshow.png', dpi=64) + diff --git a/scripts/imshow_ex.py b/scripts/imshow_ex.py new file mode 100644 index 0000000..aa53555 --- /dev/null +++ b/scripts/imshow_ex.py @@ -0,0 +1,17 @@ +from pylab import * + +def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) + +n = 10 +x = np.linspace(-3,3,3.5*n) +y = np.linspace(-3,3,3.0*n) +X,Y = np.meshgrid(x,y) +Z = f(X,Y) + +axes([0.025,0.025,0.95,0.95]) +imshow(Z,interpolation='nearest', cmap='bone', origin='lower') +colorbar(shrink=.92) + +xticks([]), yticks([]) +# savefig('../figures/imshow_ex.png', dpi=48) +show() diff --git a/scripts/linestyles.py b/scripts/linestyles.py new file mode 100644 index 0000000..83b9bdd --- /dev/null +++ b/scripts/linestyles.py @@ -0,0 +1,24 @@ +from pylab import * + +def linestyle(ls,name): + size = 256,16 + dpi = 72.0 + figsize= size[0]/float(dpi),size[1]/float(dpi) + fig = figure(figsize=figsize, dpi=dpi) + fig.patch.set_alpha(0) + axes([0,0,1,1],frameon=False) + X = np.arange(11) + Y = np.ones(11) + plot(X,Y,ls,color=(.0,.0,1,1), lw=3, ms=10, mfc=(.75,.75,1,1), mec=(0,0,1,1)) + xlim(0,10) + xticks([]), yticks([]) + print'../figures/linestyle-%s.png' % name + savefig('../figures/linestyle-%s.png' % name, dpi=dpi) + +for ls in ['-','--',':',',','o','^','v','<','>','s', + '+','x','d','1','2','3','4','h','p','|','_']: + linestyle(ls,ls) +linestyle('D', 'dd') +linestyle('H', 'hh') +linestyle('.', 'dot') +linestyle('-.', '-dot') diff --git a/scripts/linewidth.py b/scripts/linewidth.py new file mode 100644 index 0000000..582b065 --- /dev/null +++ b/scripts/linewidth.py @@ -0,0 +1,16 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,.1,1,.8], frameon=False) + +for i in range(1,11): + plot( [i,i], [0,1], color='b', lw=i/2. ) + +xlim(0,11),ylim(0,1) +xticks([]),yticks([]) +savefig('../figures/linewidth.png', dpi=dpi) + diff --git a/scripts/markers.py b/scripts/markers.py new file mode 100644 index 0000000..9b813a2 --- /dev/null +++ b/scripts/markers.py @@ -0,0 +1,47 @@ +from pylab import * + +def marker(m,name): + size = 256,16 + dpi = 72.0 + figsize= size[0]/float(dpi),size[1]/float(dpi) + fig = figure(figsize=figsize, dpi=dpi) + fig.patch.set_alpha(0) + axes([0,0,1,1],frameon=False) + X = np.arange(11) + Y = np.ones(11) + plot(X,Y,color='w', lw=1, marker=m, ms=10, mfc=(.75,.75,1,1), mec=(0,0,1,1)) + xlim(0,10) + xticks([]), yticks([]) + print '../figures/marker-%s.png' % name + savefig('../figures/marker-%s.png' % name, dpi=dpi) + +#print""" +#.. list-table:: +# :widths: 15 30 50 +# :header-rows: 1 +# +# * - Symbol +# - Description +# - Appearance +#""" +for m in [0,1,2,3,4,5,6,7,'o','h','_','1','2','3','4','8','p', + '^','v','<','>','|','d',',','+','s','*','|','x']: + if type(m) is int: + marker(m, 'i%d' % m) + #print " * - %d" % m + #print " - " + #print " - .. image:: figures/marker-i%d.png" % m + else: + marker(m,m) + #print " * - ``%s``" % m + #print " - " + #print " - .. image:: figures/marker-%s.png" % m + +marker('D', 'dd') +marker('H', 'hh') +marker('.', 'dot') +marker(r"$\sqrt{2}$", "latex") +#print " * - ``r'$\sqrt{2}$'``" +#print " - " +#print " - .. image:: figures/marker-latex.png" +#print diff --git a/scripts/mec.py b/scripts/mec.py new file mode 100644 index 0000000..fef5d17 --- /dev/null +++ b/scripts/mec.py @@ -0,0 +1,17 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +for i in range(1,11): + r,g,b = np.random.uniform(0,1,3) + plot([i,],[1,],'s', markersize=5, markerfacecolor='w', + markeredgewidth=1.5, markeredgecolor=(r,g,b,1)) +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/mec.png', dpi=dpi) + diff --git a/scripts/mew.py b/scripts/mew.py new file mode 100644 index 0000000..e9e5297 --- /dev/null +++ b/scripts/mew.py @@ -0,0 +1,15 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +for i in range(1,11): + plot([i,],[1,],'s', markersize=5, + markeredgewidth=1+i/10., markeredgecolor='k', markerfacecolor='w') +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/mew.png', dpi=dpi) diff --git a/scripts/mfc.py b/scripts/mfc.py new file mode 100644 index 0000000..0659991 --- /dev/null +++ b/scripts/mfc.py @@ -0,0 +1,16 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +for i in range(1,11): + r,g,b = np.random.uniform(0,1,3) + plot([i,],[1,],'s', markersize=8, markerfacecolor=(r,g,b,1), + markeredgewidth=.1, markeredgecolor=(0,0,0,.5)) +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/mfc.png', dpi=dpi) diff --git a/scripts/ms.py b/scripts/ms.py new file mode 100644 index 0000000..62d7f21 --- /dev/null +++ b/scripts/ms.py @@ -0,0 +1,15 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +for i in range(1,11): + plot([i,],[1,],'s', markersize=i, markerfacecolor='w', + markeredgewidth=.5, markeredgecolor='k') +xlim(0,11) +xticks([]),yticks([]) +savefig('../figures/ms.png', dpi=dpi) diff --git a/scripts/multiplot.py b/scripts/multiplot.py new file mode 100644 index 0000000..8b642e2 --- /dev/null +++ b/scripts/multiplot.py @@ -0,0 +1,32 @@ +from pylab import * + +plt.subplot(211) +gca().set_xticklabels([]) +gca().set_yticklabels([]) +#xticks([]), yticks([]) + +text(-0.05, 1.1, " Multiplot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) +text(-0.05, .925, " Plot several plots at once ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.subplot(223) +gca().set_xticklabels([]) +gca().set_yticklabels([]) +#xticks([]), yticks([]) + +plt.subplot(224) +gca().set_xticklabels([]) +gca().set_yticklabels([]) +#xticks([]), yticks([]) + +plt.savefig('../figures/multiplot.png', dpi=64) diff --git a/scripts/multiplot_ex.py b/scripts/multiplot_ex.py new file mode 100644 index 0000000..16e2238 --- /dev/null +++ b/scripts/multiplot_ex.py @@ -0,0 +1,19 @@ +from pylab import * + +fig =figure() +fig.subplots_adjust(bottom=0.025, left=0.025, top = 0.975, right=0.975) + +subplot(2,1,1) +xticks([]), yticks([]) + +subplot(2,3,4) +xticks([]), yticks([]) + +subplot(2,3,5) +xticks([]), yticks([]) + +subplot(2,3,6) +xticks([]), yticks([]) + +savefig('../figures/multiplot_ex.png',dpi=48) +show() diff --git a/scripts/pie.py b/scripts/pie.py new file mode 100644 index 0000000..b2057ac --- /dev/null +++ b/scripts/pie.py @@ -0,0 +1,31 @@ +from pylab import * + +n = 20 +X = np.ones(n) +X[-1] *= 2 +pie(X, explode=X*.05, colors = ['%f' % (i/float(n)) for i in range(n)]) + +fig = gcf() +w,h = fig.get_figwidth(), fig.get_figheight() +r = h/float(w) + +xlim(-1.5,1.5) +ylim(-1.5*r,1.5*r) +xticks([]), plt.yticks([]) + +plt.text(-0.05, 1.05, " Pie Chart \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +plt.text(-0.05, .975, " Make a pie chart of an array ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/pie.png', dpi=64) diff --git a/scripts/pie_ex.py b/scripts/pie_ex.py new file mode 100644 index 0000000..f90a7f2 --- /dev/null +++ b/scripts/pie_ex.py @@ -0,0 +1,14 @@ +from pylab import * + +n = 20 +Z = np.ones(n) +Z[-1] *= 2 + +axes([0.025,0.025,0.95,0.95]) + +pie(Z, explode=Z*.05, colors = ['%f' % (i/float(n)) for i in range(n)]) +gca().set_aspect('equal') +xticks([]), plt.yticks([]) + +# savefig('../figures/pie_ex.png',dpi=48) +show() diff --git a/scripts/plot.py b/scripts/plot.py new file mode 100644 index 0000000..abc6706 --- /dev/null +++ b/scripts/plot.py @@ -0,0 +1,27 @@ +from pylab import * + +n = 256 +X = np.linspace(0,2,n) +Y = np.sin(2*np.pi*X) + +plt.plot (X, Y, lw=2, color='violet') +xlim(-0.2,2.2), xticks([]) +ylim(-1.2,1.2), yticks([]) + +plt.text(-0.05, 1.05, " Regular Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +plt.text(-0.05, .975, " Plot lines and/or markers ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/plot.png', dpi=64) + diff --git a/scripts/plot3d-2.py b/scripts/plot3d-2.py new file mode 100644 index 0000000..159210e --- /dev/null +++ b/scripts/plot3d-2.py @@ -0,0 +1,29 @@ +from pylab import * +from mpl_toolkits.mplot3d import axes3d + + +ax = gca(projection='3d') +X, Y, Z = axes3d.get_test_data(0.05) +cset = ax.contourf(X, Y, Z) +ax.clabel(cset, fontsize=9, inline=1) + +plt.xticks([]), plt.yticks([]), +ax.set_zticks([]) + +ax.text2D(-0.05, 1.05, " 3D plots \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +ax.text2D(-0.05, .975, " Plot 2D or 3D data", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/plot3d.png', dpi=64) +plt.show() diff --git a/scripts/plot3d.py b/scripts/plot3d.py new file mode 100644 index 0000000..d461473 --- /dev/null +++ b/scripts/plot3d.py @@ -0,0 +1,34 @@ +from pylab import * +from mpl_toolkits.mplot3d import Axes3D + +fig = figure() +ax = Axes3D(fig) +X = np.arange(-4, 4, 0.25) +Y = np.arange(-4, 4, 0.25) +X, Y = np.meshgrid(X, Y) +R = np.sqrt(X**2 + Y**2) +Z = np.sin(R) + +ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.hot) +ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=cm.hot) +ax.set_zlim(-2,2) +plt.xticks([]), plt.yticks([]), +ax.set_zticks([]) + +ax.text2D(0.05, .95, " 3D plots \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +ax.text2D(0.05, .89, " Plot 2D or 3D data", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/plot3d.png', dpi=64) +plt.show() diff --git a/scripts/plot3d_ex.py b/scripts/plot3d_ex.py new file mode 100644 index 0000000..543da1d --- /dev/null +++ b/scripts/plot3d_ex.py @@ -0,0 +1,17 @@ +from pylab import * +from mpl_toolkits.mplot3d import Axes3D + +fig = figure() +ax = Axes3D(fig) +X = np.arange(-4, 4, 0.25) +Y = np.arange(-4, 4, 0.25) +X, Y = np.meshgrid(X, Y) +R = np.sqrt(X**2 + Y**2) +Z = np.sin(R) + +ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.hot) +ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=cm.hot) +ax.set_zlim(-2,2) + +# savefig('../figures/plot3d_ex.png',dpi=48) +show() diff --git a/scripts/plot_ex.py b/scripts/plot_ex.py new file mode 100644 index 0000000..4350657 --- /dev/null +++ b/scripts/plot_ex.py @@ -0,0 +1,19 @@ +from pylab import * + +n = 256 +X = np.linspace(-np.pi,np.pi,n,endpoint=True) +Y = np.sin(2*X) + +axes([0.025,0.025,0.95,0.95]) + +plot (X, Y+1, color='blue', alpha=1.00) +fill_between(X, 1, Y+1, color='blue', alpha=.25) + +plot (X, Y-1, color='blue', alpha=1.00) +fill_between(X, -1, Y-1, (Y-1) > -1, color='blue', alpha=.25) +fill_between(X, -1, Y-1, (Y-1) < -1, color='red', alpha=.25) + +xlim(-np.pi,np.pi), xticks([]) +ylim(-2.5,2.5), yticks([]) +# savefig('../figures/plot_ex.png',dpi=48) +show() diff --git a/scripts/polar.py b/scripts/polar.py new file mode 100644 index 0000000..c51fa97 --- /dev/null +++ b/scripts/polar.py @@ -0,0 +1,30 @@ +from pylab import * + +plt.subplot(111,polar=True) + +N = 20 +theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) +radii = 10*np.random.rand(N) +width = np.pi/4*np.random.rand(N) +bars = bar(theta, radii, width=width, bottom=0.0) +for r,bar in zip(radii, bars): + bar.set_facecolor( cm.jet(r/10.)) + bar.set_alpha(0.5) +gca().set_xticklabels([]) +gca().set_yticklabels([]) + +text(-0.2, 1.05, " Polar Axis \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) +text(-0.2, .975, " Plot anything using polar axis ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) +savefig('../figures/polar.png', dpi=64) + diff --git a/scripts/polar_ex.py b/scripts/polar_ex.py new file mode 100644 index 0000000..ce3de0f --- /dev/null +++ b/scripts/polar_ex.py @@ -0,0 +1,18 @@ +from pylab import * + +ax = axes([0.025,0.025,0.95,0.95], polar=True) + +N = 20 +theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) +radii = 10*np.random.rand(N) +width = np.pi/4*np.random.rand(N) +bars = bar(theta, radii, width=width, bottom=0.0) + +for r,bar in zip(radii, bars): + bar.set_facecolor( cm.jet(r/10.)) + bar.set_alpha(0.5) + +ax.set_xticklabels([]) +ax.set_yticklabels([]) +# savefig('../figures/polar_ex.png',dpi=48) +show() diff --git a/scripts/quiver.py b/scripts/quiver.py new file mode 100644 index 0000000..d26b60b --- /dev/null +++ b/scripts/quiver.py @@ -0,0 +1,31 @@ +from pylab import * + +n = 8 +X,Y = np.mgrid[0:n,0:n] +T = np.arctan2(Y-n/2.0, X-n/2.0) +R = 10+np.sqrt((Y-n/2.0)**2+(X-n/2.0)**2) +U,V = R*np.cos(T), R*np.sin(T) + +quiver(X,Y,U,V,R, alpha=.5) +quiver(X,Y,U,V, edgecolor='k', facecolor='None', linewidth=.5) + +xlim(-1,n), xticks([]) +ylim(-1,n), yticks([]) + +text(-0.05, 1.05, " Quiver Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +text(-0.05, .975, " Plot a 2-D field of arrows ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +savefig('../figures/quiver.png', dpi=64) + diff --git a/scripts/quiver_ex.py b/scripts/quiver_ex.py new file mode 100644 index 0000000..cc66440 --- /dev/null +++ b/scripts/quiver_ex.py @@ -0,0 +1,17 @@ +from pylab import * + +n = 8 +X,Y = np.mgrid[0:n,0:n] +T = np.arctan2(Y-n/2.0, X-n/2.0) +R = 10+np.sqrt((Y-n/2.0)**2+(X-n/2.0)**2) +U,V = R*np.cos(T), R*np.sin(T) + +axes([0.025,0.025,0.95,0.95]) +quiver(X,Y,U,V,R, alpha=.5) +quiver(X,Y,U,V, edgecolor='k', facecolor='None', linewidth=.5) + +xlim(-1,n), xticks([]) +ylim(-1,n), yticks([]) + +# savefig('../figures/quiver_ex.png',dpi=48) +show() diff --git a/scripts/scatter.py b/scripts/scatter.py new file mode 100644 index 0000000..f2dd030 --- /dev/null +++ b/scripts/scatter.py @@ -0,0 +1,28 @@ +from pylab import * + +n = 1024 +X = np.random.normal(0,1,n) +Y = np.random.normal(0,1,n) + +T = np.arctan2(Y,X) +scatter(X,Y,s=75,c=T,alpha=.5) +xlim(-1.5,1.5), xticks([]) +ylim(-1.5,1.5), yticks([]) + +text(-0.05, 1.05, " Scatter Plot \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +text(-0.05, .975, " Make a scatter plot of x versus y ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/scatter.png', dpi=64) + diff --git a/scripts/scatter_ex.py b/scripts/scatter_ex.py new file mode 100644 index 0000000..5dd87c1 --- /dev/null +++ b/scripts/scatter_ex.py @@ -0,0 +1,14 @@ +from pylab import * + +n = 1024 +X = np.random.normal(0,1,n) +Y = np.random.normal(0,1,n) +T = np.arctan2(Y,X) + +axes([0.025,0.025,0.95,0.95]) +scatter(X,Y, s=75, c=T, alpha=.5) + +xlim(-1.5,1.5), xticks([]) +ylim(-1.5,1.5), yticks([]) +# savefig('../figures/scatter_ex.png',dpi=48) +show() diff --git a/scripts/solid_capstyle.py b/scripts/solid_capstyle.py new file mode 100644 index 0000000..b9a5d07 --- /dev/null +++ b/scripts/solid_capstyle.py @@ -0,0 +1,20 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +plot(np.arange(4), np.ones(4), color="blue", linewidth=8, solid_capstyle = 'butt') + +plot(5+np.arange(4), np.ones(4), color="blue", linewidth=8, solid_capstyle = 'round') + +plot(10+np.arange(4), np.ones(4), color="blue", linewidth=8, solid_capstyle = 'projecting') + +xlim(0,14) +xticks([]),yticks([]) + +savefig('../figures/solid_capstyle.png', dpi=dpi) +#show() diff --git a/scripts/solid_joinstyle.py b/scripts/solid_joinstyle.py new file mode 100644 index 0000000..4c7b452 --- /dev/null +++ b/scripts/solid_joinstyle.py @@ -0,0 +1,18 @@ +from pylab import * + +size = 256,16 +dpi = 72.0 +figsize= size[0]/float(dpi),size[1]/float(dpi) +fig = figure(figsize=figsize, dpi=dpi) +fig.patch.set_alpha(0) +axes([0,0,1,1], frameon=False) + +plot(np.arange(3), [0,1,0], color="blue", linewidth=8, solid_joinstyle = 'miter') +plot(4+np.arange(3), [0,1,0], color="blue", linewidth=8, solid_joinstyle = 'bevel') +plot(8+np.arange(3), [0,1,0], color="blue", linewidth=8, solid_joinstyle = 'round') + +xlim(0,12), ylim(-1,2) +xticks([]),yticks([]) + +savefig('../figures/solid_joinstyle.png', dpi=dpi) +#show() diff --git a/scripts/subplot-grid.py b/scripts/subplot-grid.py new file mode 100644 index 0000000..7ea06fa --- /dev/null +++ b/scripts/subplot-grid.py @@ -0,0 +1,20 @@ +from pylab import * + +subplot(2,2,1) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,2,1)',ha='center',va='center',size=20,alpha=.5) + +subplot(2,2,2) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,2,2)',ha='center',va='center',size=20,alpha=.5) + +subplot(2,2,3) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,2,3)',ha='center',va='center',size=20,alpha=.5) + +subplot(2,2,4) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,2,4)',ha='center',va='center',size=20,alpha=.5) + +# savefig('../figures/subplot-grid.png', dpi=64) +show() diff --git a/scripts/subplot-horizontal.py b/scripts/subplot-horizontal.py new file mode 100644 index 0000000..684d4cc --- /dev/null +++ b/scripts/subplot-horizontal.py @@ -0,0 +1,12 @@ +from pylab import * + +subplot(2,1,1) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,1,1)',ha='center',va='center',size=24,alpha=.5) + +subplot(2,1,2) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(2,1,2)',ha='center',va='center',size=24,alpha=.5) + +# plt.savefig('../figures/subplot-horizontal.png', dpi=64) +show() diff --git a/scripts/subplot-vertical.py b/scripts/subplot-vertical.py new file mode 100644 index 0000000..e62fe0e --- /dev/null +++ b/scripts/subplot-vertical.py @@ -0,0 +1,12 @@ +from pylab import * + +subplot(1,2,1) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(1,2,1)',ha='center',va='center',size=24,alpha=.5) + +subplot(1,2,2) +xticks([]), yticks([]) +text(0.5,0.5, 'subplot(1,2,2)',ha='center',va='center',size=24,alpha=.5) + +# plt.savefig('../figures/subplot-vertical.png', dpi=64) +show() diff --git a/scripts/text.py b/scripts/text.py new file mode 100644 index 0000000..f8333db --- /dev/null +++ b/scripts/text.py @@ -0,0 +1,39 @@ +from pylab import * + +fig = plt.figure() +plt.xticks([]),plt.yticks([]) + +eqs = [] +eqs.append((r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$")) +eqs.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} = -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$")) +eqs.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$")) +eqs.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$")) +eqs.append((r"$F_G = G\frac{m_1m_2}{r^2}$")) + +for i in range(24): + index = np.random.randint(0,len(eqs)) + eq = eqs[index] + size = np.random.uniform(12,32) + x,y = np.random.uniform(0,1,2) + alpha = np.random.uniform(0.25,.75) + text(x, y, eq, ha='center', va='center', color="#11557c", alpha=alpha, + transform=gca().transAxes, fontsize=size, clip_on=True) + +text(-0.05, 1.05, " Text \n\n", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='x-large', + bbox=dict(facecolor='white', alpha=1.0, width=350,height=60), + transform = gca().transAxes) + +text(-0.05, .975, " Draw any kind of text ", + horizontalalignment='left', + verticalalignment='top', + family='Lint McCree Intl BB', + size='medium', + transform = gca().transAxes) + +plt.savefig('../figures/text.png', dpi=64) + + diff --git a/scripts/text_ex.py b/scripts/text_ex.py new file mode 100644 index 0000000..68b2030 --- /dev/null +++ b/scripts/text_ex.py @@ -0,0 +1,23 @@ +from pylab import * + +eqs = [] +eqs.append((r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$")) +eqs.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} = -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$")) +eqs.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$")) +eqs.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$")) +eqs.append((r"$F_G = G\frac{m_1m_2}{r^2}$")) + + +axes([0.025,0.025,0.95,0.95]) + +for i in range(24): + index = np.random.randint(0,len(eqs)) + eq = eqs[index] + size = np.random.uniform(12,32) + x,y = np.random.uniform(0,1,2) + alpha = np.random.uniform(0.25,.75) + text(x, y, eq, ha='center', va='center', color="#11557c", alpha=alpha, + transform=gca().transAxes, fontsize=size, clip_on=True) +xticks([]), yticks([]) +# savefig('../figures/text_ex.png',dpi=48) +show() diff --git a/scripts/ticks.py b/scripts/ticks.py new file mode 100644 index 0000000..a9c61e4 --- /dev/null +++ b/scripts/ticks.py @@ -0,0 +1,53 @@ +import matplotlib +#matplotlib.use('Agg') +from pylab import * + + +def tickline(): + + size = 512,32 + dpi = 72.0 + figsize= size[0]/float(dpi),size[1]/float(dpi) + fig = plt.figure(figsize=figsize, dpi=dpi) + fig.patch.set_alpha(0) + + ax = axes([0.05, 0, 0.9, 1], frameon=False) + xlim(0,10), ylim(-1,1), yticks([]) + ax = gca() + ax.spines['right'].set_color('none') + ax.spines['left'].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('none') + ax.xaxis.set_minor_locator(MultipleLocator(0.1)) + ax.plot(np.arange(11), np.zeros(11), color='none') + return ax + +ax = tickline() +ax.xaxis.set_major_locator(NullLocator()) +savefig('../figures/ticks-NullLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(MultipleLocator(1.0)) +savefig('../figures/ticks-MultipleLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(FixedLocator([0,2,8,9,10])) +savefig('../figures/ticks-FixedLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(IndexLocator(3,1)) +savefig('../figures/ticks-IndexLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(LinearLocator(5)) +savefig('../figures/ticks-LinearLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(LogLocator(2,[1.0])) +savefig('../figures/ticks-LogLocator.png', dpi=72) + +ax = tickline() +ax.xaxis.set_major_locator(AutoLocator()) +savefig('../figures/ticks-AutoLocator.png', dpi=72) diff --git a/scripts/ugly.py b/scripts/ugly.py new file mode 100644 index 0000000..264b622 --- /dev/null +++ b/scripts/ugly.py @@ -0,0 +1,19 @@ +import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + + +matplotlib.rc('grid',color='black',linestyle='-',linewidth=1) + +fig = plt.figure(figsize=(5,4),dpi=72) +axes = fig.add_axes([0.01, 0.01, .98, 0.98], axisbg='.75') +X = np.linspace(0,2,40,endpoint=True) +Y = np.sin(2*np.pi*X) +plt.plot (X, Y, lw=.05, c='b', antialiased=False) +plt.xticks([]) #np.arange(0.0, 2.0, 0.2)) +plt.yticks(np.arange(-1.0,1.0, 0.2)) +plt.grid() +ax = plt.gca() + +fig.savefig('../figures/ugly.png', dpi=72)