0
0
Data Analysis Pythondata~10 mins

Saving figures in Data Analysis Python - Interactive Code Practice

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

Complete the code to save the figure as a PNG file named 'plot.png'.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('plot.png')
Drag options to blanks, or click blank then click option'
Asavefig
Bshow
Cplot
Dfigure
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.show() instead of plt.savefig()
Trying to save the figure before plotting
Misspelling the function name
2fill in blank
medium

Complete the code to save the figure with a resolution of 300 dots per inch (DPI).

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig('plot.png', [1]=300)
Drag options to blanks, or click blank then click option'
Aresolution
Bquality
Cdpi
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'quality' or 'resolution' instead of 'dpi'
Not specifying the dpi parameter at all
Using an invalid parameter name
3fill in blank
hard

Fix the error in the code to save the figure as a PDF file named 'figure.pdf'.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('figure.pdf')
Drag options to blanks, or click blank then click option'
Asavefig
Bexport
Csave
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.save() or plt.export() which are not valid functions
Using plt.show() instead of saving
Misspelling the function name
4fill in blank
hard

Fill both blanks to save the figure as a JPEG file with a transparent background.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig('image.jpg', [1]=[2])
Drag options to blanks, or click blank then click option'
Atransparent
BTrue
CFalse
Dalpha
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alpha' instead of 'transparent' for background transparency
Setting transparent to False instead of True
Confusing parameter names
5fill in blank
hard

Fill all three blanks to save the figure as a high-quality SVG file with a tight bounding box.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig('diagram.svg', [1]=300, [2]='[3]')
Drag options to blanks, or click blank then click option'
Adpi
Bbbox_inches
Ctight
Dquality
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'quality' instead of 'dpi'
Not setting bbox_inches to 'tight'
Misspelling parameter names