<jupyter_start><jupyter_text>Data Visualisation Install Matplotlib`pip install matplotlib` Data Science Pipeline------------------------------ Understand the Problem Statement- Acquire Data & Cleaning- Data Visualisation / Exploratory Analysis- Machine Learning Modelling- Share Results/ Interesting Visualisations about findings<jupyter_code>import matplotlib.pyplot as plt
import numpy as np

themes = plt.style.available
print(themes)
plt.style.use("seaborn")
# Line Plot
x = np.arange(10)
y1 = x**2
y2 = 2*x + 3
print(x)
print(y1)
print(y2)
# Line Plots
plt.plot(x,y1,color='red',label="Apple",marker='o')
plt.plot(x,y2,color='green',label="Kiwi",linestyle="dashed",marker='*')
plt.xlabel("Time")
plt.ylabel("Price")
plt.title("Prices of Fruits over Time")
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text><jupyter_code>prices = np.array([1,2,3,4])**3
print(prices)
plt.plot(prices)
plt.show()<jupyter_output><empty_output><jupyter_text>Scatter Plots<jupyter_code># Adjust the Size of Any Plot
plt.figure(figsize=(6,6))
plt.scatter(x,y1,color='red',label="Apple",marker='^')
plt.scatter(x,y2,color='green',label="Kiwi",linestyle="dashed")
plt.xlabel("Time")
plt.ylabel("Price")
plt.title("Scatter Plots - Prices Over Time")
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>Bar-graphs<jupyter_code>plt.style.use("seaborn-white")
x_coordinates = np.array([0,1,2])*2
plt.bar(x_coordinates-0.25,[10,20,15],width=0.5,label="Current Year",tick_label=["Gold","Platinum","Silver"]) # Current Year
plt.bar(x_coordinates+0.25,[20,10,12],width=0.5,label="Next Year") # Next Year
plt.title("Metal Price Comparision")
plt.xlabel("Metal")
plt.ylabel("Price")
plt.ylim(0,40)
plt.xlim(-2,5)
plt.legend()
plt.show()
plt.style.use("dark_background")

plt.figure(figsize=(5,5))
x_coordinates = np.array([0,1,2])*2
plt.bar(x_coordinates-0.25,[10,20,15],width=0.5,label="Current Year",tick_label=["Gold","Platinum","Silver"],color="yellow") # Current Year
plt.bar(x_coordinates+0.25,[20,10,12],width=0.5,label="Next Year",color="orange") # Next Year
plt.title("Metal Price Comparision")
plt.xlabel("Metal")
plt.ylabel("Price")
plt.ylim(0,40)
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>Pie Chart<jupyter_code>plt.style.use("seaborn")
plt.figure(figsize=(3,3))
subjects = "Maths","Chem","Physics","English"
weightage = [20,10,15,5]

plt.pie(weightage,labels=subjects,explode=(0,0,0.1,0),autopct='%1.1f%%',shadow=True)
plt.title("Subjects ")
plt.show()<jupyter_output><empty_output><jupyter_text>Histogram<jupyter_code>Xsn = np.random.randn(100)
sigma = 8
u = 70
X = np.round(Xsn*sigma + u)
X2 = np.round(Xsn*7 + 40)

print(X,X2)
plt.style.use("seaborn")

plt.hist(X2,alpha=0.8,label="Physics")
plt.hist(X,alpha=0.9,label="Maths")
plt.ylabel("Prob/FreqCount of Students")
plt.xlabel("Marks Range")
plt.title("Histogram")
plt.show()<jupyter_output><empty_output><jupyter_text>Data Visualisation ChallengeGiven a Movies Dataset, your taskis is to make a visualisation that -- Plots the Length of Movie Title Names on X-Axis- Frequency Counts on Y-axis ie Number of Movies having 'x' characters in their title<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Read a CSV File
df = pd.read_csv("../2. Working with Libraries/movie_metadata.csv")
df.head(n=10)
df.columns
titles = list(df.get('movie_title'))
print(type(titles))
print(titles[:5])
freq_titles = {}

for title in titles:
    length = len(title)
    
    if freq_titles.get(length) is None:
        freq_titles[length] = 1
    else:
        freq_titles[length] += 1
print(freq_titles)
X = np.array(list(freq_titles.keys()))
Y = np.array(list(freq_titles.values()))
#print(X,Y)
plt.scatter(X,Y)
plt.xlabel("Length of Movie Title")
plt.ylabel("Freq Count")
plt.title("Movie Data Visualiation Problem")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18146618482188953, 'fraction_numerical': 0.030975735673722252, 'mean_word_length': 7.106694560669456, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '455165', 'license': 'MIT', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1492, 'n_words': 254, 'path': 'ml_repo/Data Visualisation/Data Visualisation.ipynb', 'repo_name': 'sachinpr0001/data_science', 'size': '3874'}