<jupyter_start><jupyter_text>Matplotlib Exercises  "import matplotlib.pyplot as plt" and set "%matplotlib inline" if you are using the jupyter notebook. What command do you use if you aren't using the jupyter notebook?<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
# %matplotlib inline
# plt.show()
x = np.arange(0,100)
y = x*2
z = x**2<jupyter_output><empty_output><jupyter_text>Exercise 1* Create a figure object called fig using plt.figure().* Use add_axes to add an axis to the figure canvas at `[0, 0, 1, 1]`. Call this new axis ax.* Plot `(x, y)` on that axes and set the labels and titles to match the plot below:<jupyter_code>sns.set(palette="bright")
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ax.plot(x, y)
ax.set_title("title")
ax.set_xlabel("x")
ax.set_ylabel("y")<jupyter_output><empty_output><jupyter_text>Exercise 2Create a figure object and put two axes on it, ax1 and ax2. Located at `[0, 0, 1, 1]` and `[0.2, 0.5, 0.2, 0.2]`, respectively.<jupyter_code>fig = plt.figure()
ax1 = fig.add_axes([0, 0, 1, 1])
ax2 = fig.add_axes([0.2, 0.5, 0.2, 0.2])<jupyter_output><empty_output><jupyter_text>Now plot `(x, y)` on both axes. And call your figure object to show it.<jupyter_code>fig = plt.figure()

ax1 = fig.add_axes([0, 0, 1, 1])
ax1.plot(x, y, color="r")
ax1.set_xlabel("x")
ax1.set_ylabel("y")

ax2 = fig.add_axes([0.2, 0.5, 0.2, 0.2])
ax2.plot(x, y, color="b")
ax2.set_xlabel("x")
ax2.set_ylabel("y")<jupyter_output><empty_output><jupyter_text>Exercise 3Create the plot below by adding two axes to a figure object at `[0, 0, 1, 1]` and `[0.2, 0.5, 0.4, 0.4]`.<jupyter_code>fig = plt.figure()
ax1 = fig.add_axes([0, 0, 1, 1])
ax2 = fig.add_axes([0.2, 0.5, 0.4, 0.4])<jupyter_output><empty_output><jupyter_text>Now use x, y, and z arrays to recreate the plot below. Notice the x limits and y limits on the inserted plot:<jupyter_code>fig = plt.figure()

# Main Plot
ax1 = fig.add_axes([0, 0, 1, 1])
ax1.plot(x, z)
ax1.set_xlabel("X")
ax1.set_ylabel("Z")

# Insert Plot
ax2 = fig.add_axes([0.2, 0.5, 0.4, 0.4])
ax2.plot(x, y)
ax2.set_title("zoom")
ax2.set_xlabel("X")
ax2.set_ylabel("Y")
ax2.set_xlim([20, 22])
ax2.set_ylim([30, 50])<jupyter_output><empty_output><jupyter_text>Exercise 4Use `plt.subplots(nrows=1, ncols=2)` to create the plot below.<jupyter_code>fig, ax = plt.subplots(nrows=1, ncols=2)
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Now plot (x, y) and (x, z) on the axes. Play around with the linewidth and style.<jupyter_code>fig, ax = plt.subplots(nrows=1, ncols=2)

ax[0].plot(x, y, color="b", linestyle="--", linewidth=2)
ax[1].plot(x, z, color="r", linestyle="-", linewidth=2)

plt.tight_layout()<jupyter_output><empty_output><jupyter_text>See if you can resize the plot by adding the figsize() argument in plt.subplots() are copying and pasting your previous code.<jupyter_code>fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 6))

ax[0].plot(x, y, color="b", linestyle="-", linewidth=2)
ax[1].plot(x, z, color="r", linestyle="--", linewidth=2)

plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1708575112830432, 'fraction_numerical': 0.04577691811734365, 'mean_word_length': 5.644539614561028, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '473955', 'license': 'MIT', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1318, 'n_words': 339, 'path': 'mk001-matplotlib_exercises.ipynb', 'repo_name': 'karakose77/python-for-data-science-and-machine-learning-exercises-and-projects', 'size': '3102'}