Skip to content

Commit 88a223c

Browse files
committed
we can go without fig.show()
for scripts it is annoying and in a notebook it is not needed
1 parent 92e5e55 commit 88a223c

File tree

10 files changed

+14
-18
lines changed

10 files changed

+14
-18
lines changed

content/code/abstracting-plot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def plot(column, label, location, color, compute_mean):
3434
# format x-axis for better date display
3535
fig.autofmt_xdate()
3636

37-
fig.show()
3837
fig.savefig(f"{month}-{column}.png")
3938

4039

content/code/add-iteration.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
# format x-axis for better date display
4646
fig.autofmt_xdate()
4747

48-
fig.show()
4948
fig.savefig(f"{month}-temperature.png")
5049

5150
fig, ax = plt.subplots()
@@ -67,5 +66,4 @@
6766
# format x-axis for better date display
6867
fig.autofmt_xdate()
6968

70-
fig.show()
7169
fig.savefig(f"{month}-precipitation.png")

content/code/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def plot(date_range, values, label, location, color, compute_mean, file_name):
6060
# format x-axis for better date display
6161
fig.autofmt_xdate()
6262

63-
# fig.show()
6463
fig.savefig(file_name)
6564

6665

content/code/initial-version-with-mean.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@
4444
# format x-axis for better date display
4545
fig.autofmt_xdate()
4646

47-
fig.show()
4847
fig.savefig("2024-01-temperature.png")

content/code/initial-version-with-precipitation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
# format x-axis for better date display
4545
fig.autofmt_xdate()
4646

47-
fig.show()
4847
fig.savefig("2024-01-temperature.png")
4948

5049
fig, ax = plt.subplots()
@@ -66,5 +65,4 @@
6665
# format x-axis for better date display
6766
fig.autofmt_xdate()
6867

69-
fig.show()
7068
fig.savefig("2024-01-precipitation.png")

content/code/initial-version.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@
3333
# format x-axis for better date display
3434
fig.autofmt_xdate()
3535

36-
fig.show()
3736
fig.savefig("2024-01-temperature.png")

content/code/small-improvements.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def plot(column, label, location, color, compute_mean):
5050
# format x-axis for better date display
5151
fig.autofmt_xdate()
5252

53-
fig.show()
5453
fig.savefig(f"{month}-{column}.png")
5554

5655

content/code/testing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def plot(date_range, values, label, location, color, compute_mean, file_name):
5656
# format x-axis for better date display
5757
fig.autofmt_xdate()
5858

59-
# fig.show()
6059
fig.savefig(file_name)
6160

6261

content/code/towards-pure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def plot(date_range, values, label, location, color, compute_mean, file_name):
5050
# format x-axis for better date display
5151
fig.autofmt_xdate()
5252

53-
# fig.show()
5453
fig.savefig(file_name)
5554

5655

content/solution.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ This is still only the January data.
6666
:::{literalinclude} code/initial-version-with-mean.py
6767
:language: python
6868
:emphasize-lines: 27-36
69+
:linenos:
6970
:::
7071
::::
7172

@@ -86,7 +87,8 @@ it for the precipitation column.
8687
::::{group-tab} Python
8788
:::{literalinclude} code/initial-version-with-precipitation.py
8889
:language: python
89-
:emphasize-lines: 50-70
90+
:emphasize-lines: 49-68
91+
:linenos:
9092
:::
9193
::::
9294

@@ -108,7 +110,8 @@ it for the precipitation column.
108110
::::{group-tab} Python
109111
:::{literalinclude} code/add-iteration.py
110112
:language: python
111-
:emphasize-lines: 15-16,22-23,28,55-56
113+
:emphasize-lines: 15-16,22-23,28,54-55
114+
:linenos:
112115
:::
113116
::::
114117

@@ -126,7 +129,8 @@ it for the precipitation column.
126129
::::{group-tab} Python
127130
:::{literalinclude} code/abstracting-plot.py
128131
:language: python
129-
:emphasize-lines: 5,54-67
132+
:emphasize-lines: 5,53-66
133+
:linenos:
130134
:::
131135
::::
132136

@@ -159,7 +163,8 @@ defined outside the function and hence there are **side-effects**.
159163
::::{group-tab} Python
160164
:::{literalinclude} code/small-improvements.py
161165
:language: python
162-
:emphasize-lines: 5-14,17-19,34,57
166+
:emphasize-lines: 5-14,17-19,34,56
167+
:linenos:
163168
:::
164169
::::
165170

@@ -183,7 +188,6 @@ before sharing the notebook.
183188
- "File" -> "Save and Export Notebook As ..." -> "Executable Script"
184189
- `git init` and commit the working version.
185190
- Add `requirements.txt` and motivate how that can be useful to have later.
186-
- In Python perhaps comment out the `fig.show()`?
187191

188192
As we continue from here, **create commits after meaningful changes** and later
189193
also share the repository with learners. This nicely connects to other lessons
@@ -203,7 +207,8 @@ We then improve towards:
203207
::::{group-tab} Python
204208
:::{literalinclude} code/towards-pure.py
205209
:language: python
206-
:emphasize-lines: 22,27-28,34,53-54,57,62,84-85
210+
:emphasize-lines: 22,27-28,34,53,56,61,83-84
211+
:linenos:
207212
:::
208213
::::
209214

@@ -229,6 +234,7 @@ they will still work.
229234
:::{literalinclude} code/testing.py
230235
:language: python
231236
:emphasize-lines: 3,23-25
237+
:linenos:
232238
:::
233239
::::
234240

@@ -260,7 +266,8 @@ they will still work.
260266
::::{group-tab} Python
261267
:::{literalinclude} code/cli.py
262268
:language: python
263-
:emphasize-lines: 1,7,67-85
269+
:emphasize-lines: 1,7,66-84
270+
:linenos:
264271
:::
265272
::::
266273

0 commit comments

Comments
 (0)