0% found this document useful (0 votes)
4 views5 pages

Python Matplotlib Plotting Examples

Uploaded by

cpanusha2116
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)
4 views5 pages

Python Matplotlib Plotting Examples

Uploaded by

cpanusha2116
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

LAB PROGRAM 06 (a)

6 a) Write a Python program to illustrate Linear Plotting using Matplotlib.

The below program demonstrates how to draw a linear plotting using Matplotlib. Make sure
you have Matplotlib installed before running this code. You can install it using pip if you
haven't already:
pip install matplotlib

PROGRAM
import [Link] as plt

# Sample data for the linear plot


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

# Create a linear plot


[Link](x, y, marker='o', linestyle='-')

# Add labels and a title


[Link]('X-Axis')
[Link]('Y-Axis')
[Link]('Linear Plot Example')

# Show the plot


[Link]() # Add a grid for better readability
[Link]()

OUTPUT
LAB PROGRAM 06 (b)
6 b) Write a Python program to illustrate liner plotting with line formatting using
Matplotlib.

The below program demonstrates how to draw a Pie chart using Matplotlib. Make sure you
have Matplotlib installed before running this code. You can install it using pip if you haven't
already:

pip install matplotlib

PROGRAM
import [Link] as plt

# Sample data for the linear plot


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

# Create a linear plot with line formatting


[Link](x, y, marker='o', color='blue', linestyle='--',
linewidth=2, markersize=8, label='Data Points')

# Add labels and a title


[Link]('X-Axis')
[Link]('Y-Axis')
[Link]('Linear Plot with Line Formatting')

# Add a legend
[Link]()

# Show the plot


[Link]()
[Link]()

OUTPUT
**********
LAB PROGRAM 07 (a)
7 a) Write a Python program which explains uses of customizing seaborn plots with
Aesthetic functions.

The below program demonstrates how to customizing seaborn plots with Aesthetic functions
using Matplotlib and Seaborn. Make sure you have Matplotlib and Seaborn installed before
running this code. You can install it using pip if you haven't already:
pip install matplotlib
pip install seaborn

PROGRAM
import seaborn as sns
import [Link] as plt

# Load a sample dataset


tips = sns.load_dataset("tips")

# Set the style of the plot


[Link](style="whitegrid")

# Create a customized bar plot


[Link](figsize=(8, 6))
[Link](x="day", y="total_bill", data=tips, palette="Blues_d")

# Customize labels and titles


[Link]("Day of the week", fontsize=12)
[Link]("Total Bill ($)", fontsize=12)
[Link]("Total Bill Amounts by Day", fontsize=14)

# Show the plot


[Link]()

OUTPUT
**********

You might also like