0% found this document useful (0 votes)
3 views4 pages

Data Visualization in Python

The document contains Python code examples for creating various visualizations using the Matplotlib library. It includes instructions for plotting car prices for different brands in 2022 and 2023, as well as a pie chart showing the distribution of land and water on Earth. Each example is accompanied by the necessary code to generate the specified graphs.

Uploaded by

mrmghrby66
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)
3 views4 pages

Data Visualization in Python

The document contains Python code examples for creating various visualizations using the Matplotlib library. It includes instructions for plotting car prices for different brands in 2022 and 2023, as well as a pie chart showing the distribution of land and water on Earth. Each example is accompanied by the necessary code to generate the specified graphs.

Uploaded by

mrmghrby66
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
You are on page 1/ 4

Visualization _Questions

1. Write a python program to display the graph as show:

Create the above graph by using the data shown below:


Car Toyota Mazda Nissan Suzuki Fiat

Price 79.000 89.000 105.000 56.000 120.000

Answer:

import matplotlib.pyplot as plt


x_values =['Toyota','Mazda','Nissan','Suzuki','Fiat']
y_values =[79.000,89.000,105.000,56.000,120.000]
plt.plot(x_values, y_values,label = "car
price",color='green')
plt.xlabel('Company')
plt.ylabel('Price')
plt.title('The Price Report')
plt.legend()
plt.show()
Visualization _Questions

2. Write a python program to display the graph as show:

Create the above graph by using the data shown below:


Car Toyota Mazda Nissan Suzuki Fiat

Price 79.000 89.000 105.000 56.000 120.000


2022
Price 85.000 95.000 120.000 70.000 150.000
2023
Visualization _Questions

Answer:

import matplotlib.pyplot as plt


x_values
=['Toyota','Mazda','Nissan','Suzuki','Fiat']
y_values =[79.000,89.000,105.000,56.000,120.000]
y2_values=[85.000,95.000,120.000,70.000,150.000]
plt.plot(x_values, y_values,label = "car price
2022",color='green')
plt.plot(x_values, y2_values,label = "car price
2023",color='orange')

plt.xlabel('Company')
plt.ylabel('Price')
plt.title('The Price Report in 2022 and 2023')
plt.legend()
plt.show()
Visualization _Questions

3. Write a python program to display the graph as show:

Answer:

import matplotlib.pyplot as plt


labels=['water','land']
values=[70,30]
color=["blue","yellow"]
plt.pie(values,labels=labels,colors=color,autopct=
"%.1f%%")
plt.title("The distribution of land and water on
Earth")
plt.legend()
plt.show()

You might also like