Skip to content

Commit b92c9f3

Browse files
committed
MAINT: Update mooreslaw tutorial plt patterns.
1 parent 58954c2 commit b92c9f3

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

content/mooreslaw-tutorial.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)