Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing PNG or JPG which are raster formats.
Using BMP which is also raster.
✗ Incorrect
SVG is a vector graphic format, which keeps the image sharp at any size.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
300 dpi is a common high resolution for raster images, making them clear.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using JPEG or GIF which are raster and not vector.
Choosing PNG which is raster.
✗ Incorrect
SVG is a vector format supported by matplotlib for saving vector graphics.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using show instead of savefig to save the plot.
Choosing PNG instead of SVG for vector output.
✗ Incorrect
Use savefig to save the plot and svg as the vector file format.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SVG which is vector instead of PNG for raster.
Not using show() to display the plot.
✗ Incorrect
PNG is a raster format, 300 dpi gives high resolution, and show() displays the plot.