0% found this document useful (0 votes)
48 views

AD3301 - Unit II Part 2.ipynb - Colaboratory

Error bars are used to indicate the estimated error or uncertainty in measurements on a graph. They are drawn above and below the data points and can be short, showing more precise measurements, or long, showing more variable data. Error bars are usually symmetrical but may be uneven if the data is skewed. Contour plots display the relationship between three variables - two independent variables on the x and y axes and one dependent variable represented by contours of equal value.

Uploaded by

palaniappan.cse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

AD3301 - Unit II Part 2.ipynb - Colaboratory

Error bars are used to indicate the estimated error or uncertainty in measurements on a graph. They are drawn above and below the data points and can be short, showing more precise measurements, or long, showing more variable data. Error bars are usually symmetrical but may be uneven if the data is skewed. Contour plots display the relationship between three variables - two independent variables on the x and y axes and one dependent variable represented by contours of equal value.

Uploaded by

palaniappan.cse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

10/3/22, 12:12 PM AD3301 - Unit II Part 2.

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.

import matplotlib.pyplot as plt


import numpy as np

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'

Gaussian process regression (GPR), using the Scikit-Learn

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)

plt.fill_between(x, y - y_err, y + y_err,


color='red', alpha=.2)

Density and Contour Plots

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)

contour plot is used to explore the relationship between three variables.


https://colab.research.google.com/drive/1CZJIrV_hzeqoej7MWKcUfI63lr152R6z#printMode=true 2/4
10/3/22, 12:12 PM AD3301 - Unit II Part 2.ipynb - Colaboratory

These plots display two independent variables (X, Y) and one dependent variable (Z).

plt.contour for contour plots,

plt.contourf for filled contour plots, and

plt.imshow for showing images

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()

Filled Coutour plots using coutourf

plt.contourf(X, Y, Z,30,cmap='RdGy')
plt.colorbar()

plt.imshow(Z, extent=[0, 5, 0, 5], origin='lower',


cmap='RdGy')
plt.colorbar()
plt.axis(aspect='image');

Histograms, Binnings, and Density


[ ] ↳ 6 cells hidden

Two-Dimensional Histograms and Binnings

plt.hist2d: Two-dimensional histogram


[ ] ↳ 1 cell hidden

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

plt.hexbin: Hexagonal binnings


[ ] ↳ 1 cell hidden

Customizing Plot Legends


[ ] ↳ 8 cells hidden

Multiple Legends
[ ] ↳ 1 cell hidden

Customizing Colorbars
[ ] ↳ 16 cells hidden

Colab paid products - Cancel contracts here

https://colab.research.google.com/drive/1CZJIrV_hzeqoej7MWKcUfI63lr152R6z#printMode=true 4/4

You might also like