- Matplotlib - Transforms
- Matplotlib - Working with Images
- Mathematical Expressions
- Matplotlib - Working With Text
- Matplotlib - 3D Surface plot
- Matplotlib - 3D Wireframe plot
- Matplotlib - 3D Contour Plot
- Three-dimensional Plotting
- Matplotlib - Violin Plot
- Matplotlib - Box Plot
- Matplotlib - Quiver Plot
- Matplotlib - Contour Plot
- Matplotlib - Scatter Plot
- Matplotlib - Pie Chart
- Matplotlib - Histogram
- Matplotlib - Bar Plot
- Matplotlib - Twin Axes
- Setting Ticks and Tick Labels
- Matplotlib - Setting Limits
- Matplotlib - Formatting Axes
- Matplotlib - Grids
- Matplotlib - Subplot2grid() Function
- Matplotlib - Subplots() Function
- Matplotlib - Multiplots
- Matplotlib - Axes Class
- Matplotlib - Figure Class
- Object-oriented Interface
- Matplotlib - PyLab module
- Matplotlib - Simple Plot
- Matplotlib - Pyplot API
- Matplotlib - Jupyter Notebook
- Matplotlib - Anaconda distribution
- Matplotlib - Environment Setup
- Matplotlib - Introduction
- Matplotlib - Home
Matplotlib Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Matplotpb - Contour Plot
Contour plots (sometimes called Level Plots) are a way to show a three-dimensional surface on a two-dimensional plane. It graphs two predictor variables X Y on the y-axis and a response variable Z as contours. These contours are sometimes called the z-spces or the iso-response values.
A contour plot is appropriate if you want to see how alue Z changes as a function of two inputs X and Y, such that Z = f(X,Y). A contour pne or isopne of a function of two variables is a curve along which the function has a constant value.
The independent variables x and y are usually restricted to a regular grid called meshgrid. The numpy.meshgrid creates a rectangular grid out of an array of x values and an array of y values.
Matplotpb API contains contour() and contourf() functions that draw contour pnes and filled contours, respectively. Both functions need three parameters x,y and z.
import numpy as np import matplotpb.pyplot as plt xpst = np.pnspace(-3.0, 3.0, 100) ypst = np.pnspace(-3.0, 3.0, 100) X, Y = np.meshgrid(xpst, ypst) Z = np.sqrt(X**2 + Y**2) fig,ax=plt.subplots(1,1) cp = ax.contourf(X, Y, Z) fig.colorbar(cp) # Add a colorbar to a plot ax.set_title( Filled Contours Plot ) #ax.set_xlabel( x (cm) ) ax.set_ylabel( y (cm) ) plt.show()Advertisements