Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Marsden committed May 22, 2024
1 parent 42f84c1 commit dc48896
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 27 deletions.
14 changes: 12 additions & 2 deletions 02_creating_plots.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ <h2> Contents </h2>

<section class="tex2jax_ignore mathjax_ignore" id="creating-plots">
<h1>02: Creating Plots<a class="headerlink" href="#creating-plots" title="Permalink to this heading">#</a></h1>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-r notranslate"><div class="highlight"><pre><span></span><span class="nf">library</span><span class="p">(</span><span class="n">IRdisplay</span><span class="p">)</span>
<span class="nf">display_html</span><span class="p">(</span><span class="s">&#39;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/MXr3tp6Q1aA&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><iframe width="560" height="315" src="https://www.youtube.com/embed/MXr3tp6Q1aA" frameborder="0" allowfullscreen></iframe></div></div>
</div>
<p>In this chapter we will look at how to plot data from a NetCDF file. We will look at a 1D data variable as well as some 2D data that we will plot on a map. Let’s load in some libraries that we will use.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -711,7 +721,7 @@ <h2>Plotting 2D data on a map<a class="headerlink" href="#plotting-2d-data-on-a-
<div class="cell_input docutils container">
<div class="highlight-r notranslate"><div class="highlight"><pre><span></span><span class="nf">ggplot</span><span class="p">(</span><span class="n">df</span><span class="p">,</span><span class="w"> </span><span class="nf">aes</span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lon</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lat</span><span class="p">,</span><span class="w"> </span><span class="n">fill</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">anom</span><span class="p">))</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">geom_tile</span><span class="p">()</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">scale_fill_gradient2</span><span class="p">(</span><span class="n">low</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;blue&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">mid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;white&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">high</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;red&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">midpoint</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="p">,</span><span class="w"> </span><span class="n">limits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="nf">min</span><span class="p">(</span><span class="n">df</span><span class="o">$</span><span class="n">anom</span><span class="p">),</span><span class="w"> </span><span class="nf">max</span><span class="p">(</span><span class="n">df</span><span class="o">$</span><span class="n">anom</span><span class="p">)))</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">scale_fill_gradient2</span><span class="p">(</span><span class="n">low</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;blue&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">mid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;white&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">high</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;red&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">midpoint</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="p">,</span><span class="w"> </span><span class="n">limits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="m">-10</span><span class="p">,</span><span class="m">10</span><span class="p">))</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">coord_fixed</span><span class="p">(</span><span class="n">ratio</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1.5</span><span class="p">)</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">theme_minimal</span><span class="p">()</span><span class="w"> </span><span class="o">+</span>
<span class="w"> </span><span class="nf">labs</span><span class="p">(</span><span class="n">fill</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Temperature anomaly (°C)&quot;</span><span class="p">)</span><span class="w"> </span><span class="o">+</span>
Expand All @@ -723,7 +733,7 @@ <h2>Plotting 2D data on a map<a class="headerlink" href="#plotting-2d-data-on-a-
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/2651a0806da61dadc296d10b89d56d8f70dbc57b929a0d63f5ed29134354dfb3.png" src="_images/2651a0806da61dadc296d10b89d56d8f70dbc57b929a0d63f5ed29134354dfb3.png" />
<img alt="_images/60f24e813924d397d1ab1379ab7560f741ee0d194f4412772648b0a3f965c65f.png" src="_images/60f24e813924d397d1ab1379ab7560f741ee0d194f4412772648b0a3f965c65f.png" />
</div>
</div>
<p>Maybe we want to zoom in on a certain region.</p>
Expand Down
75 changes: 51 additions & 24 deletions _sources/02_creating_plots.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit dc48896

Please sign in to comment.