...

/

Coloured and 3-D Graphs

Coloured and 3-D Graphs

Let’s learn about creating colored and 3-D graphs using matplotlib.

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:

Press + to interact
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)

The

...