<jupyter_start><jupyter_text>Demonstrating "state-based" vs. "object-oriented" programming in Pyplot __by [<NAME>](https://gist.github.com/KalebNyquist)__This Jupyter Notebook provides the code used to generate the figures in the Medium post ["plt.subplot() or plt.subplots()? Understanding state-based vs. object-oriented programming in Pyplot"](https://towardsdatascience.com/plt-subplot-or-plt-subplots-understanding-state-based-vs-object-oriented-programming-in-pyplot-4ba0c7283f5d) published in _Towards Data Science_.  Import Relevant Packages<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Create Random Data<jupyter_code># X-Axis
data_x = np.linspace(0, 1000, 25)

# Y-Axis
np.random.seed(502)
data_t = np.random.rand(25)
increment = 1
data_y = []
for each in data_t:
    data_y.append(each*increment)
    increment += .065 * increment<jupyter_output><empty_output><jupyter_text>State-Based Approach — _plt.subplot()_<jupyter_code>plt.figure(facecolor='lightgrey')
plt.subplot(2,2,1)
plt.plot(data_x, data_y, 'r-')
plt.subplot(2,2,2)
plt.plot(data_x, data_y, 'b-')
plt.subplot(2,2,4)
plt.plot(data_x, data_y, 'g-')
# plt.suptitle("Your Title Here")
# plt.xlabel("X Axis")
# plt.ylabel("Y Axis")<jupyter_output><empty_output><jupyter_text>Object-Oriented Approach — _plt.subplots()_<jupyter_code>fig, ax = plt.subplots(2,2)
fig.set_facecolor('lightgrey')
ax[0,0].plot(data_x, data_y, 'r-')
ax[0,1].plot(data_x, data_y, 'b-')
fig.delaxes(ax[1,0])
ax[1,1].plot(data_x, data_y, 'g-')
# fig.suptitle("Your Title Here")
# ax[1,1].set_xlabel("X Axis")
# ax[1,1].set_ylabel("Y Axis")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1595744680851064, 'fraction_numerical': 0.027186761229314422, 'mean_word_length': 6.948356807511737, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '213602', 'license': 'MIT', 'n_tokens_mistral': 728, 'n_tokens_neox': 692, 'n_words': 117, 'path': 'State-Based vs. OOP in Pyplot.ipynb', 'repo_name': 'KalebNyquist/statebased_vs_oop_pyplot', 'size': '1699'}