0% found this document useful (0 votes)
34 views11 pages

Matplotlib Plot Examples in Python

The document contains a series of Python code snippets using Matplotlib to create various types of plots, including line plots, scatter plots, bar charts, histograms, pie charts, and 3D scatter plots. Each snippet demonstrates how to visualize data related to dramas, ratings, and views with appropriate labels and titles. The examples illustrate the versatility of Matplotlib for data visualization in Python.

Uploaded by

niralishrimali57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views11 pages

Matplotlib Plot Examples in Python

The document contains a series of Python code snippets using Matplotlib to create various types of plots, including line plots, scatter plots, bar charts, histograms, pie charts, and 3D scatter plots. Each snippet demonstrates how to visualize data related to dramas, ratings, and views with appropriate labels and titles. The examples illustrate the versatility of Matplotlib for data visualization in Python.

Uploaded by

niralishrimali57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Shrimali Nidhi

EnrollMent Number:-226140307126
Subject:-IML(4350701)

Input:-

import [Link] as plt

x = [10, 20, 30, 40, 50]

y = [1, 4, 9, 16, 25]

[Link](x, y)

[Link]('X Axis')

[Link]('Y Axis')

[Link]('Line Plot Example')

[Link]()

Output:-
Input:-

import [Link] as plt

x = [1, 2, 3, 4, 5, 6]

y = [10, 44, 99, 11, 25,21]

[Link](x, y)

[Link]('X Axis')

[Link]('Y Axis')

[Link]('Scatter Plot Example')

[Link]()

Output:-
Input:-

import [Link] as plt

drama = ['F4', '2gether', 'Devil sis', 'Arsenal Military', 'Vincenzo']

rate = [99, 80, 70, 98, 60]

[Link](drama, rate)

[Link]('Drama;s')

[Link]('Rates')

[Link]('Bar Chart Example')

[Link]()

Output:-
Input:-

import [Link] as plt

import numpy as np

data = [Link](1000)

[Link](data, bins=30)

[Link]('Values')

[Link]('Frequency')

[Link]('Histogram Example')

[Link]()

Output:-
Input:-

import [Link] as plt

import numpy as np

y = [Link]([20, 20, 30, 25, 25])

mylabels = ["Lovely Runner", "Hostel Lake", "True Beauty", "Hidden Love", "Business Proposal"]

[Link](y, labels = mylabels)

[Link]()

[Link]()

Output:-
Input:-

import [Link] as plt

drama = ["The Labyrinth", "Goedam", "The Mysterious Class", "Talk to me", "Haunted Asylum"]

views = [1000000, 1500000, 800000, 1200000, 900000] # Example view counts

[Link](drama, views, marker='o',color = 'black')

plt.fill_between(drama, views, alpha=0.2,color = 'black')

[Link]("Drama Title")

[Link]("Views (in millions)")

[Link](" Drama Views")

[Link]()

Output:
Input:-

import [Link] as plt

import numpy as np

data = [Link](10, 10)

[Link](data, cmap='hot', interpolation='nearest')

[Link]()

[Link]("X-axis")

[Link]("Y-axis")

[Link]()

Output:-

Input:-

import [Link] as plt

drama = ["The Good Doctor", "Grey's Anatomy", "The Resident", "New Amsterdam", "Chicago Med"]

views = [
[100000, 120000, 150000, 180000, 200000],

[110000, 130000, 160000, 190000, 210000],

[120000, 140000, 170000, 200000, 220000]

[Link](drama, views[0], views[1], views[2], labels=["Week 1", "Week 2", "Week 3"])

[Link]("Drama Title")

[Link]("Views (in thousands)")

[Link]("American Drama Views Over Time")

[Link]()

[Link]()

Output:-

Input:-

import [Link] as plt

import numpy as np
drama = ["Hometown Cha-Cha-Cha", "Vincenzo", "Goblin", "Strong Woman Do Bong-soon", "Crash
Landing on You"]

ratings = [ [8, 7, 9, 6, 8, 7], [9, 8, 10, 7, 9, 8, [7, 6, 8, 5, 7, 6], [8, 7, 9, 6, 8, 7], [9, 10, 9, 8, 10, 9] ] ]

[Link](ratings, labels=drama)

[Link]('Drama')

[Link]('Ratings')

[Link]('Box Plot of Drama Ratings')

[Link](rotation=45) # Rotate x-axis labels for better readability

[Link]()

Output:-
Input:-

import [Link] as plt

import numpy as np

from mpl_toolkits.mplot3d import Axes3D

dramas = ["Breaking Bad", "Game of Thrones", "Stranger Things", "The Walking Dead", "Friends"]

seasons = [5, 8, 4, 11, 10]

ratings = [9.5, 9.2, 8.7, 8.2, 8.9]

fig = [Link](figsize=(10, 6))

ax = fig.add_subplot(111, projection='3d')

[Link](seasons, ratings, range(len(dramas)), c='skyblue', s=100)

ax.set_xlabel('Seasons')

ax.set_ylabel('Ratings')

ax.set_zlabel('Drama')

ax.set_zticks(range(len(dramas)))

ax.set_zticklabels(dramas)

ax.set_title('3D Scatter Plot of American Dramas')

[Link]()

OutPut:-

You might also like