0
0
Matplotlibdata~10 mins

Error bar plots 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 create an error bar plot with y-error.

Matplotlib
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 3, 5, 7]
yerr = [0.2, 0.3, 0.1, 0.4]

plt.errorbar(x, y, [1]=yerr)
plt.show()
Drag options to blanks, or click blank then click option'
Ax
Bxerr
Cyerr
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'xerr' instead of 'yerr' for vertical error bars.
Passing the error values as 'x' or 'y' parameters.
2fill in blank
medium

Complete the code to add marker style 'o' to the error bar plot.

Matplotlib
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 3, 5, 7]
yerr = [0.2, 0.3, 0.1, 0.4]

plt.errorbar(x, y, yerr=yerr, [1]='o')
plt.show()
Drag options to blanks, or click blank then click option'
Amarker
Bcolor
Clinestyle
Dlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'linestyle' to try to set markers.
Confusing 'color' with marker style.
3fill in blank
hard

Fix the error in the code to correctly plot horizontal error bars.

Matplotlib
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 3, 5, 7]
xerr = [0.1, 0.2, 0.1, 0.3]

plt.errorbar(x, y, [1]=xerr)
plt.show()
Drag options to blanks, or click blank then click option'
Ay
Byerr
Cx
Dxerr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'yerr' for horizontal error bars.
Passing error values as 'x' or 'y' parameters.
4fill in blank
hard

Fill both blanks to create an error bar plot with red color and dashed line style.

Matplotlib
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 3, 5, 7]
yerr = [0.2, 0.3, 0.1, 0.4]

plt.errorbar(x, y, yerr=yerr, [1]=[2])
plt.show()
Drag options to blanks, or click blank then click option'
Acolor
Blinestyle
C'red'
D'--'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping color and linestyle parameters.
Using color names without quotes.
5fill in blank
hard

Fill all three blanks to create an error bar plot with blue color, circle markers, and dotted line style.

Matplotlib
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 3, 5, 7]
yerr = [0.2, 0.3, 0.1, 0.4]

plt.errorbar(x, y, yerr=yerr, [1]=[2], [3]='o')
plt.show()
Drag options to blanks, or click blank then click option'
Acolor
B'blue'
Clinestyle
D':'
Attempts:
3 left
💡 Hint
Common Mistakes
Using color values without quotes.
Confusing linestyle symbols.