0% found this document useful (0 votes)
5 views2 pages

Python

The document provides Python code for creating various types of plots using Matplotlib and Pandas. It includes examples of a simple line plot, a custom line plot for books read monthwise, a bar chart comparing names and ages, and a subplot example with multiple plots. Each section demonstrates how to visualize data effectively using different plotting techniques.

Uploaded by

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

Python

The document provides Python code for creating various types of plots using Matplotlib and Pandas. It includes examples of a simple line plot, a custom line plot for books read monthwise, a bar chart comparing names and ages, and a subplot example with multiple plots. Each section demonstrates how to visualize data effectively using different plotting techniques.

Uploaded by

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

import matplotlib.

pyplot as plt

import numpy as np

import pandas as pd

# ⿡ Simple Line Plot

x = [2, 4, 5, 7, 3]

y = [4, 8, 10, 14, 6]

[Link](x, y)

[Link]("Simple Line Plot")

[Link]("X-axis")

[Link]("Y-axis")

[Link]()

# ⿢ Custom Line Plot (Books Read Monthwise)

x = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]

y = [1, 4, 3, 2, 7, 6, 9, 8, 10, 5]

[Link](x, y, color="red")

[Link]('Books Read')

[Link]('Months')

[Link]('Books Read Monthwise')

[Link]()

# ⿣ Bar Chart using Pandas DataFrame

data = {'Name': ['Amit', 'Mayank', 'Mohit', 'Raju', 'Pooja'],

'Age': [40, 30, 45, 50, 25]}

df = [Link](data)

[Link](kind='bar', x='Name', y='Age', color='green', title='Name Vs Age')

[Link]()
# ⿤ Subplots Example

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

ax1 = fig.add_subplot(2, 2, 1)

ax2 = fig.add_subplot(2, 2, 2)

ax3 = fig.add_subplot(2, 2, 3)

x = [Link](0, 2 * [Link], 400)

y = [Link](x ** 2)

[Link](x, y)

ax1.set_title("Plot 1")

[Link](x, [Link](x))

ax2.set_title("Plot 2")

[Link](x, [Link](x) * [Link](x))

ax3.set_title("Plot 3")

plt.tight_layout()

[Link]()

You might also like