Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Nov 10, 2024
1 parent 52ed035 commit 7c1c05c
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
caf4b903
315cd6c8
116 changes: 74 additions & 42 deletions learn/learn-python/module-3/3-manipulating-data.html

Large diffs are not rendered by default.

33 changes: 23 additions & 10 deletions learn/learn-python/module-3/4-displaying-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ <h2>Python data plotting library</h2>
<section id="what-is-matplotlib.pyplot" class="slide level2">
<h2>What is matplotlib.pyplot?</h2>
<ul>
<li>A library for plotting data in Python.</li>
<li>A library for plotting data in python.</li>
<li>It is a powerful tool for creating graphs and charts.</li>
<li>It is widely used in data science and machine learning.</li>
<li>It is easy to use and has a wide range of features.</li>
Expand Down Expand Up @@ -452,6 +452,12 @@ <h2>Let’s plot some 1D data</h2>
<img data-src="../../../media/1d-plot-pyplot-basic.png" class="centre-full-image top-55 r-stretch"></section>
<section id="lets-plot-some-1d-data-2" class="slide level2">
<h2>Let’s plot some 1D data</h2>
<ul>
<li>We can however improve this plot by adding some labels and a title.</li>
</ul>
</section>
<section id="lets-plot-some-1d-data-3" class="slide level2">
<h2>Let’s plot some 1D data</h2>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>pyplot_1d.py</strong></pre>
Expand All @@ -467,7 +473,7 @@ <h2>Let’s plot some 1D data</h2>
<span id="cb2-9"><a></a>plot.show()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="lets-plot-some-1d-data-3" class="slide level2">
<section id="lets-plot-some-1d-data-4" class="slide level2">
<h2>Let’s plot some 1D data</h2>

<img data-src="../../../media/1d-plot-pyplot.png" class="centre-full-image top-55 r-stretch"></section>
Expand All @@ -488,7 +494,7 @@ <h2>Plotting 2D data</h2>
<div class="code-with-filename-file">
<pre><strong>pyplot_2d.py</strong></pre>
</div>
<div class="sourceCode" id="cb3" data-filename="pyplot_2d.py" data-code-line-numbers="4,10"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a></a>array_2x7 <span class="op">=</span> np.array([[<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>, <span class="dv">7</span>],</span>
<div class="sourceCode" id="cb3" data-filename="pyplot_2d.py" data-code-line-numbers="4,10"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a></a>array_2x7 <span class="op">=</span> np.array([[<span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>, <span class="dv">7</span>],</span>
<span id="cb3-2"><a></a> [<span class="dv">8</span>, <span class="dv">9</span>, <span class="dv">10</span>, <span class="dv">11</span>, <span class="dv">12</span>, <span class="dv">13</span>, <span class="dv">13</span>]])</span>
<span id="cb3-3"><a></a></span>
<span id="cb3-4"><a></a>plot.imshow(array_2x7)</span>
Expand All @@ -507,16 +513,23 @@ <h2>Plotting 2D data</h2>
<section id="plotting-2d-data-2" class="slide level2">
<h2>Plotting 2D data</h2>
<ul>
<li>We too we can improve things with this plot.</li>
<li>Let’s add a colour bar, a title, labels and format the y-axis ticks.</li>
</ul>
</section>
<section id="plotting-2d-data-3" class="slide level2">
<h2>Plotting 2D data</h2>
<ul>
<li>Heatmaps are useful</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>pyplot_2d.py</strong></pre>
</div>
<div class="sourceCode" id="cb4" data-filename="pyplot_2d.py" data-code-line-numbers="4-9"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a></a>array_2x7 <span class="op">=</span> np.array([[<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>, <span class="dv">7</span>],</span>
<div class="sourceCode" id="cb4" data-filename="pyplot_2d.py" data-code-line-numbers="4-9"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a></a>array_2x7 <span class="op">=</span> np.array([[<span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>, <span class="dv">7</span>],</span>
<span id="cb4-2"><a></a> [<span class="dv">8</span>, <span class="dv">9</span>, <span class="dv">10</span>, <span class="dv">11</span>, <span class="dv">12</span>, <span class="dv">13</span>, <span class="dv">13</span>]])</span>
<span id="cb4-3"><a></a></span>
<span id="cb4-4"><a></a>plot.imshow(array_2x7, cmap<span class="op">=</span><span class="st">'viridis'</span>, aspect<span class="op">=</span><span class="st">'auto'</span>)</span>
<span id="cb4-4"><a></a>plot.imshow(array_2x7, aspect<span class="op">=</span><span class="st">'auto'</span>)</span>
<span id="cb4-5"><a></a>plot.colorbar()</span>
<span id="cb4-6"><a></a>plot.title(<span class="st">"2x7 Array Heatmap"</span>)</span>
<span id="cb4-7"><a></a>plot.gca().set_yticks(np.arange(array_2x7.shape[<span class="dv">0</span>]))</span>
Expand All @@ -525,7 +538,7 @@ <h2>Plotting 2D data</h2>
<span id="cb4-10"><a></a>plot.show()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="plotting-2d-data-3" class="slide level2">
<section id="plotting-2d-data-4" class="slide level2">
<h2>Plotting 2D data</h2>

<img data-src="../../../media/2d-heatmap-pyplot.png" class="centre-full-image top-55 r-stretch"></section>
Expand All @@ -549,7 +562,7 @@ <h2>Plotting 3D data</h2>
<section id="plotting-3d-data-1" class="slide level2 smaller">
<h2>Plotting 3D data</h2>
<ul>
<li>3D scatter plots are useful</li>
<li>3D scatter plots are useful.</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
Expand All @@ -561,7 +574,7 @@ <h2>Plotting 3D data</h2>
<span id="cb6-4"><a></a>x, y, z <span class="op">=</span> np.indices(array_3D.shape)</span>
<span id="cb6-5"><a></a>values <span class="op">=</span> array_3D.flatten()</span>
<span id="cb6-6"><a></a></span>
<span id="cb6-7"><a></a>sc <span class="op">=</span> ax.scatter(x.flatten(), y.flatten(), z.flatten(), c<span class="op">=</span>values, cmap<span class="op">=</span><span class="st">'viridis'</span>, s<span class="op">=</span><span class="dv">100</span>)</span>
<span id="cb6-7"><a></a>sc <span class="op">=</span> ax.scatter(x.flatten(), y.flatten(), z.flatten(), c<span class="op">=</span>values)</span>
<span id="cb6-8"><a></a></span>
<span id="cb6-9"><a></a></span>
<span id="cb6-10"><a></a></span>
Expand Down Expand Up @@ -590,13 +603,13 @@ <h2>Plotting 3D data</h2>
<div class="code-with-filename-file">
<pre><strong>pyplot_3d.py</strong></pre>
</div>
<div class="sourceCode" id="cb7" data-filename="pyplot_3d.py" data-code-line-numbers="8-19"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a></a>fig <span class="op">=</span> plot.figure()</span>
<div class="sourceCode" id="cb7" data-filename="pyplot_3d.py" data-code-line-numbers="7-18"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a></a>fig <span class="op">=</span> plot.figure()</span>
<span id="cb7-2"><a></a>ax <span class="op">=</span> fig.add_subplot(<span class="dv">111</span>, projection<span class="op">=</span><span class="st">'3d'</span>)</span>
<span id="cb7-3"><a></a></span>
<span id="cb7-4"><a></a>x, y, z <span class="op">=</span> np.indices(array_3D.shape)</span>
<span id="cb7-5"><a></a>values <span class="op">=</span> array_3D.flatten()</span>
<span id="cb7-6"><a></a></span>
<span id="cb7-7"><a></a>sc <span class="op">=</span> ax.scatter(x.flatten(), y.flatten(), z.flatten(), c<span class="op">=</span>values, cmap<span class="op">=</span><span class="st">'viridis'</span>, s<span class="op">=</span><span class="dv">100</span>)</span>
<span id="cb7-7"><a></a>sc <span class="op">=</span> ax.scatter(x.flatten(), y.flatten(), z.flatten(), c<span class="op">=</span>values, s<span class="op">=</span><span class="dv">100</span>)</span>
<span id="cb7-8"><a></a></span>
<span id="cb7-9"><a></a>cbar_ax <span class="op">=</span> fig.add_axes([<span class="fl">0.9</span>, <span class="fl">0.15</span>, <span class="fl">0.05</span>, <span class="fl">0.7</span>]) </span>
<span id="cb7-10"><a></a>cbar <span class="op">=</span> fig.colorbar(sc, ax<span class="op">=</span>ax, cax<span class="op">=</span>cbar_ax, shrink<span class="op">=</span><span class="fl">0.5</span>, aspect<span class="op">=</span><span class="dv">5</span>)</span>
Expand Down
7 changes: 5 additions & 2 deletions learn/learn-python/module-3/5-manipulating-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ <h2>Loading Images</h2>
<ul>
<li>To manipulate images, we first need to load them into our environment.</li>
<li>In Python, we can use the <code>PIL</code> (also called Pillow) module from <code>Image</code>.</li>
<li>Note we are using <code>imshow()</code> now and not just <code>show()</code>.</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
Expand Down Expand Up @@ -524,7 +525,7 @@ <h2>Cropping Images</h2>
<li>Then use the <code>crop</code> method from the <code>PIL</code> library.</li>
<li>This uses pixel coordinates.</li>
<li>The top-left corner is (0, 0).</li>
<li>coordinates are x and then y values.</li>
<li>Coordinates are (new_top_left_x, new_top_left_y, new_bottom_right_x, new_bottom_right_y).</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
Expand All @@ -551,7 +552,8 @@ <h2>Rotate Images</h2>
<section id="inverting-images" class="slide level2" data-background-image="../../../media/inverted-landscape-glass-sphere.jpg" data-background-opacity="0.4">
<h2>Inverting Images</h2>
<ul>
<li>Invert by using the <code>invert</code> method.</li>
<li>Here we can invert the colours of an image.</li>
<li>Use the <code>invert</code> method.</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
Expand All @@ -565,6 +567,7 @@ <h2>Inverting Images</h2>
<section id="change-file-type" class="slide level2" data-background-image="../../../media/file-cabinets-old.jpg" data-background-opacity="0.4">
<h2>Change file type</h2>
<ul>
<li>Specify the new file type in the name and then,</li>
<li>Use the <code>save</code> method from the <code>PIL</code> library to save the image in a different format.</li>
</ul>
<div class="code-with-filename">
Expand Down
Binary file modified media/3d-scatterplot-pyplot-basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/gaussian-like-graph.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7c1c05c

Please sign in to comment.