0
0
Matplotlibdata~10 mins

Vector vs raster output decision in Matplotlib - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to save the plot as a vector graphic.

Matplotlib
plt.savefig('plot.[1]')
Drag options to blanks, or click blank then click option'
Apng
Bbmp
Cjpg
Dsvg
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing PNG or JPG which are raster formats.
Using BMP which is also raster.
2fill in blank
medium

Complete the code to save the plot as a raster image with high resolution.

Matplotlib
plt.savefig('plot.png', dpi=[1])
Drag options to blanks, or click blank then click option'
A1
B300
C10
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using very low dpi like 1 or 10 which makes images blurry.
Choosing 50 dpi which is low quality.
3fill in blank
hard

Fix the error in the code to save a vector graphic with matplotlib.

Matplotlib
plt.savefig('figure.[1]')
Drag options to blanks, or click blank then click option'
Asvg
Bjpeg
Cgif
Dpng
Attempts:
3 left
💡 Hint
Common Mistakes
Using JPEG or GIF which are raster and not vector.
Choosing PNG which is raster.
4fill in blank
hard

Fill both blanks to create a plot and save it as a vector graphic.

Matplotlib
plt.plot(x, y)
plt.[1]('output.[2]')
Drag options to blanks, or click blank then click option'
Asavefig
Bshow
Csvg
Dpng
Attempts:
3 left
💡 Hint
Common Mistakes
Using show instead of savefig to save the plot.
Choosing PNG instead of SVG for vector output.
5fill in blank
hard

Fill all three blanks to save a raster image with high resolution and display it.

Matplotlib
plt.plot(data)
plt.savefig('image.[1]', dpi=[2])
plt.[3]()
Drag options to blanks, or click blank then click option'
Asvg
B300
Cshow
Dpng
Attempts:
3 left
💡 Hint
Common Mistakes
Using SVG which is vector instead of PNG for raster.
Not using show() to display the plot.