Search⌘ K
AI Features

Coloured and 3-D Graphs

Explore techniques for visualizing data using Matplotlib, including creating colored pseudocolor plots, 2D contour graphs, and 3D surface and wireframe plots. Understand how to combine 2D and 3D graphics to enhance data interpretation.

Color and contour

Colormaps and contour figures are very useful for plotting functions of two variables. In most of these functions, we encode one dimension of the data using a colormap.

Let’s learn with a simple example:

Python 3.5
alpha = 0.7
phi_ext = 2 * np.pi * 0.5
# creating custom function which returns some computation
def flux_qubit_potential(phi_m, phi_p):
return 2 + alpha - 2 * np.cos(phi_p) * np.cos(phi_m) - alpha * np.cos(phi_ext - 2*phi_p)
phi_m = np.linspace(0, 2*np.pi, 100)# create an evenly spaced sequence in a specified interval.
phi_p = np.linspace(0, 2*np.pi, 100)# create an evenly spaced sequence in a specified interval.
X,Y = np.meshgrid(phi_p, phi_m) # creating a rectangular grid with the help of the given 1-D arrays that represent the Matrix indexing or Cartesian indexing.
Z = flux_qubit_potential(X, Y).T # Function call for the function in above cell
print("X : ", X)
print("Y : ", Y)
print("Z : ", Z)

...