Create a pseudocolor plot of an unstructured triangular grid in Python using Matplotlib
Matplotlib is a Python module which can be used for data visualization; and analyse the data graphically in the form of pie-chart, histogram, bar graph and many more. It also has an ability to generate MATLAB-like frameworks.
Unstructured triangular grid
An unstructured triangular grid contains n_points points and n_tri triangles which can either be specified by the user or automatically generated using a Delaunay triangulation.
Syntax : matplotlib.tri.Triangulation(x, y, triangles=None, mask=None)
- x, y : specifies coordinates of grid points.
- triangles : [optional] integer array-like of shape (n_tri, 3)
- mask : [optional] it specifies which triangles are masked out.
Creating a pseudocolor plot of an unstructured triangular grid
We can plot a pseudo-color unstructured triangular grid with the tripcolor() function of the pyplot library.
Syntax : matplotlib.pyplot.tripcolor(*args, cmap=None, alpha=1.0, edgecolors=None, facecolors=None, shading=’flat’, norm=None, vmax=None, vmin=None, **kwargs)
- cmap : It can be None or matplotlib has a number of built-in colormaps accessible via matplotlib.cm.get_cmap
- alpha : It can be None or alpha value between 0 to 1.
- edgecolors :
- If its None, edges will not be visible.
- ‘face’ represents the same color as faces.
- color sequence will set a color.
- facecolors : Mention the typefaces
- shading : It can be either ‘flat’ or ‘gouraud’
- norm : If its None defaults to normalize().
- vimax : It can be either None or the scalar value.
- vimin : It can be either None or the scalar value. ( vimax and vimin are used in conjunction with normalize data)
Example 1 :
Example 2 :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course