forked from pygeode/pygeode.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut_plot.html
191 lines (177 loc) · 11.5 KB
/
tut_plot.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Plotting — PyGeode 1.0 alpha documentation</title>
<link rel="stylesheet" href="_static/pygtheme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0 alpha',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="PyGeode 1.0 alpha documentation" href="index.html" />
<link rel="up" title="Tutorial" href="tutorial.html" />
<link rel="next" title="Working with Axes" href="tut_axes.html" />
<link rel="prev" title="Variable input and output" href="tut_io.html" />
<link href="http://fonts.googleapis.com/css?family=Ubuntu:300,300italic,regular,italic,500,500italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="tut_axes.html" title="Working with Axes"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="tut_io.html" title="Variable input and output"
accesskey="P">previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="tutorial.html" accesskey="U">Tutorial</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="plotting">
<h1>Plotting<a class="headerlink" href="#plotting" title="Permalink to this headline">¶</a></h1>
<p>The plotting system in PyGeode is intended to provide sensible defaults so that
you can quickly see a reasonably annotated plot of the contents of a PyGeode
variable, but also to allow as much flexibility in customizing your plots as
possible. In general it is intended to map very closely to the matplotlib
library, and to give you access to as much of the matplotlib functionality as
possible. This tutorial is intended to introduce some of the basic concepts; a
gallery is also available with sample plots. Though you could use either
document as a starting point for plotting even without any matplotlib
experience, both will make more sense if you have had some.</p>
<p>There are three levels of plotting commands. The highest levels, mostly prefixed
by <tt class="docutils literal"><span class="pre">show</span></tt>, make the most assumptions about the structur of the plot they
produce. The next level, prefixed with <tt class="docutils literal"><span class="pre">v</span></tt>, are lower level wrappers around
matplotlib commands that are aware of PyGeode variables and try to make
formatting decisions accordingly. The lowest level are very thin wrappers around
individual matplotlib commands that know nothing about PyGeode variables, but
allow for the most direct control.</p>
<p>The basic high-level plotting command is <a class="reference internal" href="plot.html#pygeode.showvar" title="pygeode.showvar"><tt class="xref py py-func docutils literal"><span class="pre">showvar()</span></tt></a>, which in its
simplest form will plot a one or two dimensional variable:</p>
<div class="highlight-ipython"><div class="highlight"><pre><span class="gp">In [1]: </span><span class="kn">import</span> <span class="nn">pygeode</span> <span class="kn">as</span> <span class="nn">pyg</span><span class="p">;</span> <span class="kn">from</span> <span class="nn">pygeode.tutorial</span> <span class="kn">import</span> <span class="n">t1</span><span class="p">,</span> <span class="n">t2</span>
<span class="c"># A line plot</span>
<span class="gp">In [1]: </span><span class="n">pyg</span><span class="o">.</span><span class="n">showvar</span><span class="p">(</span><span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="p">(</span><span class="n">lat</span><span class="o">=</span><span class="mi">45</span><span class="p">))</span>
<span class="c"># A contour plot</span>
<span class="gp">In [1]: </span><span class="n">pyg</span><span class="o">.</span><span class="n">showvar</span><span class="p">(</span><span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="p">)</span>
</pre></div>
</div>
<a class="reference internal image-reference" href="_images/showvar1d.png"><img alt="_images/showvar1d.png" src="_images/showvar1d.png" style="width: 4in;" /></a>
<a class="reference internal image-reference" href="_images/showvar2d.png"><img alt="_images/showvar2d.png" src="_images/showvar2d.png" style="width: 4in;" /></a>
<p>The axes are labelled and formatted according to behaviour set by the axis
objects (explained in more detail below), and the title is set from the variable
name, and the coordinates of any degenerate axes. In the case of the contour
plot, a colorbar is added automatically.</p>
<div class="section" id="line-plots">
<h2>Line Plots<a class="headerlink" href="#line-plots" title="Permalink to this headline">¶</a></h2>
<p>If <a class="reference internal" href="plot.html#pygeode.showvar" title="pygeode.showvar"><tt class="xref py py-func docutils literal"><span class="pre">showvar()</span></tt></a> is passed a one dimensional variable, it will produce a
line plot (ultimately using <tt class="xref py py-func docutils literal"><span class="pre">matplotlib.plot()</span></tt>), automatically extracting
the coordinates and values from the variable. If the axis is recognized by
PyGeode as being a vertical axis, the plot will be transposed. This can be
reversed if desired by setting the keyword argument <tt class="docutils literal"><span class="pre">transpose</span> <span class="pre">=</span> <span class="pre">True</span></tt>.</p>
<p>Like the plot command, the format of the line can be set by passing a string
immediately following the command; moreover, any other keyword argument
recognized by <tt class="xref py py-func docutils literal"><span class="pre">matplotlib.plot()</span></tt> will be passed through.</p>
<div class="highlight-ipython"><div class="highlight"><pre><span class="c"># A vertical plot</span>
<span class="gp">In [1]: </span><span class="n">pyg</span><span class="o">.</span><span class="n">showvar</span><span class="p">(</span><span class="n">t2</span><span class="o">.</span><span class="n">Temp</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="s">'time'</span><span class="p">,</span> <span class="s">'lat'</span><span class="p">,</span> <span class="s">'lon'</span><span class="p">),</span> <span class="s">'k--'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mf">3.</span><span class="p">)</span>
<span class="c"># A transposed plot</span>
<span class="gp">In [1]: </span><span class="n">pyg</span><span class="o">.</span><span class="n">showvar</span><span class="p">(</span><span class="n">t2</span><span class="o">.</span><span class="n">Temp</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="s">'time'</span><span class="p">,</span> <span class="s">'lat'</span><span class="p">,</span> <span class="s">'lon'</span><span class="p">),</span> <span class="n">transpose</span> <span class="o">=</span> <span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
<a class="reference internal image-reference" href="_images/lp_vertical.png"><img alt="_images/lp_vertical.png" src="_images/lp_vertical.png" style="width: 4in;" /></a>
<a class="reference internal image-reference" href="_images/lp_transpose.png"><img alt="_images/lp_transpose.png" src="_images/lp_transpose.png" style="width: 4in;" /></a>
<p>Notice that these commands all return a <tt class="xref py py-class docutils literal"><span class="pre">AxesWrapper</span></tt> object - this
holds all the data and settings used to contruct your plot, and it can be used
to make further modifications.</p>
</div>
<div class="section" id="contour-plots">
<h2>Contour Plots<a class="headerlink" href="#contour-plots" title="Permalink to this headline">¶</a></h2>
<p>Customizing contour levels</p>
<p>basic plotting command; plotvar</p>
<p>1d plots: - simple? axis annotation, titles, plotting to a particular axis, overplotting</p>
<p>2d plots: specifying contour levels, filled vs lines; colorbar, projection, contour labels, pcolor,
overplotting</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Plotting</a><ul>
<li><a class="reference internal" href="#line-plots">Line Plots</a></li>
<li><a class="reference internal" href="#contour-plots">Contour Plots</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="tut_io.html"
title="previous chapter">Variable input and output</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="tut_axes.html"
title="next chapter">Working with Axes</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/tut_plot.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="tut_axes.html" title="Working with Axes"
>next</a> |</li>
<li class="right" >
<a href="tut_io.html" title="Variable input and output"
>previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="tutorial.html" >Tutorial</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2013, Mike Neish, Peter Hitchcock.
Last updated on Sep 13, 2015.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>