<jupyter_start><jupyter_text>This line is only for jupyter notebooks, for another editor, simply we use: **plt.show()** at the end of all your plotting commands to have the figure pop up in another window.  Basic plot<jupyter_code>x = np.arange(1,10)
y = x ** 2
plt.plot(x, y, 'r')
plt.plot(x, y, 'r')
plt.title('any Title')
plt.plot(x, y, 'r')
plt.title('any Title')
plt.xlabel('X Axis Label')
plt.ylabel('Y Axis Label')<jupyter_output><empty_output><jupyter_text>Customizing figure height and width<jupyter_code>fig = plt.figure(figsize = (12,8))
plt.plot(x, y, 'r')
plt.title('any Title')
plt.xlabel('X Axis Label')
plt.ylabel('Y Axis Label')<jupyter_output><empty_output><jupyter_text>Saving the visualization output<jupyter_code>fig.savefig("first.png")
cars = pd.read_csv("cars93.csv")
cars.head()<jupyter_output><empty_output><jupyter_text>Box Plot<jupyter_code>fig = plt.figure(figsize = (12,8))
plt.boxplot(cars["Price"])
plt.title("Boxplot of Price")
plt.show()
B = plt.boxplot(cars["Price"])
[item.get_ydata()[1] for item in B['whiskers']]
fig = plt.figure(figsize = (12,8))
plt.boxplot(cars["Horsepower"])
plt.title("Boxplot of Horsepower")
plt.show()
# using Pandas
cars["Horsepower"].plot.box(figsize = (10,7))
plt.show()<jupyter_output><empty_output><jupyter_text>Histogram<jupyter_code>a = np.arange(17)
plt.scatter(a, np.zeros_like(a))
plt.scatter(cars["Horsepower"], np.zeros_like(cars["Horsepower"]))
plt.show()
plt.hist(cars["Horsepower"])
plt.title("Histogram of Horsepower")
plt.show()
plt.hist(cars["Horsepower"], bins = 16)
plt.title("Histogram of Horsepower")
plt.show()<jupyter_output><empty_output><jupyter_text>Bar Chart<jupyter_code>cars["Type"].value_counts()
plt.bar(cars["Type"].value_counts().index, cars["Type"].value_counts().values)
plt.xlabel("Type")
plt.ylabel("Count")
plt.title("Distribution of Type across various categories")
plt.show()
plt.bar(cars["Type"].values, cars["MPG.city"],width=0.2,label="Mileage in city")
plt.xlabel("Type")
plt.ylabel("MPG.city")
plt.title("MPG.city across the car types")
plt.show()
grouped_df = cars.groupby("Type").mean()
grouped_df
grouped_df.reset_index(inplace = True)
plt.bar(grouped_df["Type"], grouped_df["MPG.city"])
plt.xlabel("Type")
plt.ylabel("MPG.city")
plt.title("MPG.city mean across the car types")
plt.show()<jupyter_output><empty_output><jupyter_text>Scatter plot<jupyter_code>plt.scatter(cars["Horsepower"], cars["MPG.city"])
plt.xlabel("Horsepower")
plt.ylabel("MPG.city")
plt.title("Scatter plot of Horsepower vs. MPG.city")
plt.show()
plt.scatter(cars["Horsepower"], cars["MPG.city"], c = "r",marker = "*")
plt.xlabel("Horsepower")
plt.ylabel("MPG.city")
plt.title("Scatter plot of Horsepower vs. MPG.city")
plt.show()<jupyter_output><empty_output><jupyter_text>Line Chart<jupyter_code>plt.plot(cars["Horsepower"], cars["MPG.city"])
cars93_ordered = cars.sort_values(by = "Horsepower") 
cars93_ordered.head()
plt.plot(cars93_ordered["Horsepower"], cars93_ordered["MPG.city"])
plt.xlabel("Horsepower")
plt.ylabel("MPG.city")
plt.title("Line chart of Horsepower vs. MPG.city")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18612903225806451, 'fraction_numerical': 0.01064516129032258, 'mean_word_length': 8.256716417910448, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '18150', 'license': 'MIT', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1206, 'n_words': 205, 'path': '05 Matplotlib and Seaborn/Matplotlib/Matplotlib.ipynb', 'repo_name': 'Anil-matcha/ISTE-Examly-Sessions', 'size': '3100'}