Exercise 1: Figure vs. Axes, and Why fig, ax = plt.subplots() Scales Better — Possible Solution ==================================================================== FIGURE VS. AXES, PER THIS CHAPTER ------------------------------ Per this chapter, "a Figure is the whole canvas — the entire window or image being produced. An Axes is one individual plot area within that figure, with its own x-axis, y-axis, and content. A figure can hold one Axes, or several arranged in a grid." The Figure is the outer container — the full image file or window that ultimately gets saved or displayed. An Axes is what actually holds one chart's own data, gridlines, and labels; a single Figure can contain multiple Axes side by side, each showing a different chart. WHY THE OLDER plt.plot() STYLE GETS CONFUSING WITH MULTIPLE CHARTS ------------------------------ Per this chapter's own tip-box, "a shorter, older style (plt.plot(...) directly, with no explicit figure or axes) also exists and still works — but it implicitly tracks 'the current figure' behind the scenes, which gets confusing fast once more than one chart is involved." Without explicitly naming which Axes a given plotting call should affect, matplotlib has to guess based on some hidden, globally- tracked "current" figure and axes — a guess that becomes ambiguous and error-prone the moment a script is working with more than one chart at once, since it's no longer obvious from the code itself which plotting call is meant to affect which chart. WHY NAMING fig AND ax EXPLICITLY AVOIDS THIS ------------------------------ Per this chapter's own example, ax.plot(), ax.set_title(), etc. are all called directly on a specific, named ax object — there's no ambiguity about which Axes is being modified, because it's stated explicitly in every line of code rather than relying on matplotlib's own hidden "current" tracking. If a script later creates a second Axes (say, ax2), each plotting call still names exactly which Axes it targets, with no risk of accidentally drawing onto the wrong subplot. WHY THIS MATTERS FOR THIS COURSE'S OWN CHOICE OF STYLE ------------------------------ Per this chapter, this explicit style "scales cleanly to multiple subplots and is the style used consistently through the rest of this course." Since ds1-9's own EDA methodology will likely need to compare several charts side by side to spot patterns, choosing the explicit, unambiguous fig/ax style from the very first visualization chapter avoids having to relearn a different, more error-prone approach later once multiple charts genuinely become necessary. WHY THIS WORKS AS AN ANSWER ------------------------------ It defines Figure and Axes precisely using the chapter's own wording, explains the specific ambiguity the older plt.plot() style introduces once multiple charts are involved, and explains why explicitly naming fig and ax removes that ambiguity by making every plotting call's own target explicit rather than implicit.