0
0
Data Analysis Pythondata~15 mins

Saving figures in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Saving figures
📖 Scenario: You have created a simple line plot showing sales data over a week. Now, you want to save this plot as an image file so you can share it or use it in reports.
🎯 Goal: Create a line plot using sales data and save the figure as a PNG file named sales_plot.png.
📋 What You'll Learn
Create a list called sales with the values: 150, 200, 250, 300, 280, 320, 400
Create a list called days with the values: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'
Use matplotlib to plot sales against days
Save the figure as sales_plot.png using matplotlib's savefig method
Print the message "Figure saved as sales_plot.png" after saving
💡 Why This Matters
🌍 Real World
Saving figures is important when you want to share your data visualizations with others or include them in reports and presentations.
💼 Career
Data scientists and analysts often save plots to communicate insights clearly and professionally.
Progress0 / 4 steps
1
Create sales and days data lists
Create a list called sales with these exact values: 150, 200, 250, 300, 280, 320, 400. Also create a list called days with these exact values: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'.
Data Analysis Python
Hint

Use square brackets to create lists. Separate values with commas.

2
Import matplotlib and set up the plot
Import matplotlib.pyplot as plt. Then use plt.plot(days, sales) to create a line plot of sales over days.
Data Analysis Python
Hint

Use import matplotlib.pyplot as plt to import. Then call plt.plot(days, sales).

3
Save the figure as a PNG file
Use plt.savefig('sales_plot.png') to save the current figure as a PNG file named sales_plot.png.
Data Analysis Python
Hint

Use plt.savefig('sales_plot.png') to save the figure.

4
Print confirmation message
Write a print statement to display the message "Figure saved as sales_plot.png" after saving the figure.
Data Analysis Python
Hint

Use print("Figure saved as sales_plot.png") to show the message.