0
0
Matplotlibdata~10 mins

Figure size for publication in Matplotlib - Interactive Code Practice

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

Complete the code to set the figure size to 6 inches wide and 4 inches tall.

Matplotlib
import matplotlib.pyplot as plt
plt.figure(figsize=([1], 4))
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
Drag options to blanks, or click blank then click option'
A8
B4
C6
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using pixels instead of inches.
2fill in blank
medium

Complete the code to create a figure with width 8 inches and height 3 inches.

Matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=([1], 3))
ax.plot([0, 1], [0, 1])
plt.show()
Drag options to blanks, or click blank then click option'
A8
B3
C5
D6
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing width and height order.
Using integers as strings.
3fill in blank
hard

Fix the error in the code to set the figure size to 5 inches wide and 2 inches tall.

Matplotlib
import matplotlib.pyplot as plt
plt.figure(figsize=[1])
plt.plot([1, 2], [3, 4])
plt.show()
Drag options to blanks, or click blank then click option'
A5, 2
B[5, 2]
C{5, 2}
D(5, 2)
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets [] instead of parentheses.
Passing two separate numbers without tuple.
4fill in blank
hard

Fill both blanks to create a figure with width 7 inches and height 5 inches, then plot a line.

Matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=([1], [2]))
ax.plot([0, 1, 2], [2, 3, 4])
plt.show()
Drag options to blanks, or click blank then click option'
A7
B6
C5
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using incorrect numbers.
5fill in blank
hard

Fill all three blanks to create a figure with width 4 inches, height 3 inches, and plot a red dashed line.

Matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=([1], [2]))
ax.plot([1, 2, 3], [3, 2, 1], linestyle=[3], color='red')
plt.show()
Drag options to blanks, or click blank then click option'
A3
B'--'
C4
D'-.'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong order for width and height.
Using wrong linestyle string.