Skip to content

Latest commit

 

History

History
152 lines (146 loc) · 2.91 KB

Part6-Types-of-Plots-3.md

File metadata and controls

152 lines (146 loc) · 2.91 KB

Contour graph


  • Contour plots are aslo called Level Plots.
  • Contour plots are a way to show a three-dimensional area on a two-dimensional plane.
  • It shows the X and the Y variable on the Y axis , and the Z on the X axis.
  • contour() function draws contour lines.
  • contourf() function draws filled contours.
  • Both functions require three parameters x,y and z.
Example:
17.
xlist = np.linspace(-10.0, 10.0, 100)

ylist = np.linspace(-5.0,53.0, 100)

X, Y = np.meshgrid(xlist, ylist)

Z = np.sqrt(X**2 + Y**2)

fig,ax=plt.subplots(1,1)

cp = ax.contourf(X, Y, Z)

fig.colorbar(cp)

ax.set_title('Filled Contours Plot')

ax.set_ylabel('y (cm)')

plt.show()
Output:



Box Plot


  • A Box Plot is also known as Whisker plot
  • In a box plot, we draw a box from the first quartile to the third quartile.

Syntax:
matplotlib.pyplot.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_ticks=True, autorange=False, zorder=None, data=None)
18.
np.random.seed(10)

data = np.random.normal(50, 20, 100)

plt.boxplot(data)

plt.show()



19.
np.random.seed(10)

data_1 = np.random.normal(10, 10, 500)

data_2 = np.random.normal(80, 20, 500)

data_3 = np.random.normal(40, 30, 500)

data_4 = np.random.normal(70, 40, 500)

data = [data_1, data_2, data_3, data_4]

fg = plt.figure(figsize =(10, 7))

axis = fg.add_axes([0, 0, 1, 1])

bp = axis.boxplot(data)

plt.show()



Working with images


We need to import matplotlib.image for working with images.

20.
import matplotlib.image as mpimg
img = mpimg.imread('DevIncept.png')
plt.imsave("logo.png", img, cmap = 'gray')
imgplot = plt.imshow(img)



And we can continue playing with these!