Syntax error Setting the display range suplot of errorbars in matplotlib

Setting the display range suplot of errorbars in matplotlib



To set the display range subplot or errorbars in matplotlib, we can take the following steps −

  • Set the figure size and adjust the padding between and around the subplots.
  • Create x and y data points using numpy.
  • Create a figure and a set of subplots.
  • Plot y versus x as lines and/or markers with attached errorbars.
  • To display the figure, use show() method.

Example

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)

fig, ax = plt.subplots()
ax.errorbar(x, y, xerr=0.2, yerr=0.4)

plt.show()

Output

Updated on: 2021-08-03T12:17:31+05:30

126 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements