Skip to content

Commit 5e4ecb9

Browse files
committed
Merge pull request #295 from rossbar/matplotlib-nopyplot
MAINT: Replace `plt.<cmd>` pattern with explicit fig/ax calls 4e0b558
1 parent cd37753 commit 5e4ecb9

51 files changed

Lines changed: 431 additions & 429 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/01-mooreslaw-tutoria-b7ed0ec7045e43a575dc871f1d80ba79.png renamed to build/01-mooreslaw-tutoria-68d0ad466c300d347c517c09cd29d0d9.png

File renamed without changes.

build/11-breakpoints-4a4e876329815e1ff29bcf307e3a5cde.png renamed to build/11-breakpoints-a3f29c8d952b84c3ef15c4eabbef8b15.png

File renamed without changes.

build/11-delhi-aqi-719dde59d7502416fd089cc1a3ee750a.jpg renamed to build/11-delhi-aqi-5fa295dd14ed05daaf4cd0193122e2f7.jpg

File renamed without changes.

build/11-one-tailed-test-91a73715acaa0890e9788172075e053c.svg renamed to build/11-one-tailed-test-26f804268f5109df12b6c8bf7575a889.svg

File renamed without changes.
File renamed without changes.

build/contributing-f7ceb3a0f108d7fc3bdd1bb7874388fe.md renamed to build/contributing-37b3727293093b313267e063ca1315a0.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/mooreslaw-tutorial-54a5b5de6b09bac5fef2234e35ceddf0.md renamed to build/mooreslaw-tutorial-52947d6b10f577764cbf1947772e04d5.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,23 @@ The style sheet replicates
289289
```{code-cell}
290290
transistor_count_predicted = np.exp(B) * np.exp(A * year)
291291
transistor_Moores_law = Moores_law(year)
292+
292293
plt.style.use("fivethirtyeight")
293-
plt.semilogy(year, transistor_count, "s", label="MOS transistor count")
294-
plt.semilogy(year, transistor_count_predicted, label="linear regression")
294+
295+
fig, ax = plt.subplots()
296+
ax.semilogy(year, transistor_count, "s", label="MOS transistor count")
297+
ax.semilogy(year, transistor_count_predicted, label="linear regression")
295298
296299
297-
plt.plot(year, transistor_Moores_law, label="Moore's Law")
298-
plt.title(
300+
ax.plot(year, transistor_Moores_law, label="Moore's Law")
301+
ax.set_title(
299302
"MOS transistor count per microprocessor\n"
300303
+ "every two years \n"
301304
+ "Transistor count was x{:.2f} higher".format(np.exp(A * 2))
302305
)
303-
plt.xlabel("year introduced")
304-
plt.legend(loc="center left", bbox_to_anchor=(1, 0.5))
305-
plt.ylabel("# of transistors\nper microprocessor")
306+
ax.set_xlabel("year introduced")
307+
ax.set_ylabel("# of transistors\nper microprocessor")
308+
ax.legend(loc="center left", bbox_to_anchor=(1, 0.5))
306309
```
307310

308311
_A scatter plot of MOS transistor count per microprocessor every two years with a red line for the ordinary least squares prediction and an orange line for Moore's law._
@@ -346,19 +349,20 @@ y = np.linspace(2016.5, 2017.5)
346349
your_model2017 = np.exp(B) * np.exp(A * y)
347350
Moore_Model2017 = Moores_law(y)
348351
349-
plt.plot(
352+
fig, ax = plt.subplots()
353+
ax.plot(
350354
2017 * np.ones(np.sum(year == 2017)),
351355
transistor_count2017,
352356
"ro",
353357
label="2017",
354358
alpha=0.2,
355359
)
356-
plt.plot(2017, transistor_count2017.mean(), "g+", markersize=20, mew=6)
360+
ax.plot(2017, transistor_count2017.mean(), "g+", markersize=20, mew=6)
357361
358-
plt.plot(y, your_model2017, label="Your prediction")
359-
plt.plot(y, Moore_Model2017, label="Moores law")
360-
plt.ylabel("# of transistors\nper microprocessor")
361-
plt.legend()
362+
ax.plot(y, your_model2017, label="Your prediction")
363+
ax.plot(y, Moore_Model2017, label="Moores law")
364+
ax.set_ylabel("# of transistors\nper microprocessor")
365+
ax.legend()
362366
```
363367

364368
The result is that your model is close to the mean, but Gordon

0 commit comments

Comments
 (0)