import pylab as pl
import numpy as np
import math
X = np.linspace(-999999,999999)
Y = (X+math.sqrt(X**2+2*X))
pl.plot(X,Y)
pl.show()
Y = X+np.sqrt(X**2+2*X
X = np.arange(10000)
timeit Y = map(lambda x: (x+math.sqrt(x**2+2*x)), X)
10 loops, best of 3: 82.1 ms per loop
timeit Y = X+np.sqrt(X**2+2*X)
The errorbar() function in pyplot module of matplotlib library is used to plot y versus x as lines and/or markers with attached errorbars.
Syntax: matplotlib.pyplot.errorbar(x, y, yerr=None, xerr=None, fmt=”, ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, \*, data=None, \*\*kwargs)
Parameters: This method accept the following parameters that are described below:
- x, y: These parameter are the horizontal and vertical coordinates of the data points.
- fmt: This parameter is an optional parameter and it contains the string value.
- xerr, yerr: These parameter contains an array.And the error array should have positive values.
- ecolor: This parameter is an optional parameter. And it is the color of the errorbar lines with default value NONE.
- elinewidth: This parameter is also an optional parameter. And it is the linewidth of the errorbar lines with default value NONE.
- capsize: This parameter is also an optional parameter. And it is the length of the error bar caps in points with default value NONE.
- barsabove: This parameter is also an optional parameter. It contains boolean value True for plotting errorsbars above the plot symbols.Its default value is False.
- lolims, uplims, xlolims, xuplims: These parameter are also an optional parameter. They contain boolean values which is used to indicate that a value gives only upper/lower limits.
- errorevery: This parameter is also an optional parameter. They contain integer values which is used to draws error bars on a subset of the data.