AD3301 - Unit II Part 2.ipynb - Colaboratory
AD3301 - Unit II Part 2.ipynb - Colaboratory
ipynb - Colaboratory
Error Bars
Error bars help you indicate estimated error or uncertainty to give a general sense of how
precise a measurement is
This is done through the use of markers drawn over the original graph and its data points
A short error bar shows that values are concentrated signaling that the plotted averaged value is
more likely while
A long error bar would indicate that the values are more spread out and less reliable
The length of each pair of error bars tends to be of equal length on both sides,
however, if the data is skewed then the lengths on each side would be unbalanced.
x = np.linspace(0,10,10)
y = np.exp(-x)
# plotting graph
plt.plot(x, y)
x_err = np.random.random_sample(10)
https://colab.research.google.com/drive/1CZJIrV_hzeqoej7MWKcUfI63lr152R6z#printMode=true 1/4
10/3/22, 12:12 PM AD3301 - Unit II Part 2.ipynb - Colaboratory
plt.errorbar(x, y,
xerr=x_err,
fmt='-o',
color='yellow',
ecolor='red')
y_err = np.random.random_sample(10)
plt.errorbar(x, y,
yerr=y_err,
fmt='-o',
color='yellow',
ecolor='green')
Code Text
x_err = np.random.random_sample(10)
y_err = np.random.random_sample(10)
plt.errorbar(x, y,
xerr=x_err,
yerr=y_err,
fmt='-o',
color='yellow',
ecolor='hotpink',
elinewidth=5, capsize=0)
# Change fmt = '.k'
x_err = np.random.random_sample(10)
y_err = np.random.random_sample(10)
plt.errorbar(x, y)
#xerr=x_err,yerr=y_err,fmt='-o',color='yellow',ecolor='hotpink',elinewidth=2, capsize=0)
A contour diagram is simply a graph on the xy-plane that shows curves of equal height for a two-
variable function
z = f(x, y)
These plots display two independent variables (X, Y) and one dependent variable (Z).
import numpy as np
import matplotlib.pyplot as plt
xlist = np.linspace(-3.0, 3.0, 100)
ylist = np.linspace(-3.0, 3.0, 100)
X, Y = np.meshgrid(xlist, ylist)
Z = np.sqrt(X**2 + Y**2)
plt.contour(X, Y, Z, colors='black')
plt.contour(X, Y, Z,30,cmap='RdGy')
plt.colorbar()
plt.contourf(X, Y, Z,30,cmap='RdGy')
plt.colorbar()
https://colab.research.google.com/drive/1CZJIrV_hzeqoej7MWKcUfI63lr152R6z#printMode=true 3/4
10/3/22, 12:12 PM AD3301 - Unit II Part 2.ipynb - Colaboratory
Multiple Legends
[ ] ↳ 1 cell hidden
Customizing Colorbars
[ ] ↳ 16 cells hidden
https://colab.research.google.com/drive/1CZJIrV_hzeqoej7MWKcUfI63lr152R6z#printMode=true 4/4