Skip to content
C

Problem 3: Save a Figure to a File

Easypython

Problem Description

Write a Python program that creates a simple chart and saves it as a PNG file with a specified DPI, before displaying it.

Input

Simple chart data, a filename, and a DPI value.

Output

A saved image file, and the displayed chart.

Constraints

  • None specific.

Example Input

text
data=[1,2,3,4], filename="my_chart.png", dpi=200

Example Output

text
(A file "my_chart.png" is created, and the chart is also displayed)

Concepts Covered

plt.savefig(), dpi parameter, correct call order.

Input (stdin)

Output

Run your code to see output here...