Spherical to Cartesian coordinate ellipsoid overlap - python

I have two geographic coordinates; latitude and longitude , separated by few meters.
I need to draw an ellipsoid of same major and minor axes ,centered around the geographic co-ordinates
I used matplot lib and numpy to draw the ellipsoid.
I am calculating the cartesian coordinates for the longitude using the formula given below
To shift the ellipsoid to the lat and long co-rodinates, I am adding all the x,y,z array elements with catesian coordinates of longitude- x1, y1, z1
Is that the right way to shift the ellipsoid , so that if I draw another ellipsoid with a different geographic co-ordinate I will be able to visualize/calculate their overlap area
radius_of_world = 6371000
# Radii corresponding to the coefficients:
# http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node42.html ?
rx, ry, rz = 1/np.sqrt(coefs) # Is this correct for coefs gives as a,b,v
# Set of all spherical angles:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
# Postion of the lattitude and logitude on surface of the earth// ellipsoidal earth
x1 = radius_of_world * cos(longitude) * cos(latitude)
y1 = radius_of_world * np.sin(longitude) * np.cos(latitude)
z1 = radius_of_world * np.sin(latitude)
print 'Point location is', x1,y1,z1
# Cartesian coordinates that correspond to the spherical angles:
# (this is the equation of an ellipsoid):
x = rx * np.outer(np.cos(u), np.sin(v))
y = ry * np.outer(np.sin(u), np.sin(v))
z = rz * np.outer(np.ones_like(u), np.cos(v))
# Plot:
#ax.plot_wireframe(x +x1 , y + y1, z + z1, rstride=4, cstride=4, color=color)
ax.scatter(x +x1, y + y1, z + z1,color=color )
I am not sure if the calculation of rx, ry,rz is correct; I changed it slightly for seeing it in 2D and now I can see a and b coming with proper length
Testing Elliptical Drawing in Spherical Corodinates
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(12,12)) # Square figure
def drawCoverage(coefs,latitude,longitude,color):
# Radii corresponding to the coefficients:
# http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node42.html ??
rx, ry = coefs # This is what I changed
# Set of all spherical angles:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
# u = np.pi/2
# v = np.pi/2
# Cartesian coordinates that correspond to the spherical angles:
# (this is the equation of an ellipsoid):
x = rx * np.outer(np.cos(u), np.sin(v))
y = ry * np.outer(np.sin(u), np.sin(v))
#ax.autoscale(enable=True)
# Plot:
#plt.axis([0,100,0,100])
plt.plot(x , y , 'bo' )
latitude,longitude= 13.04738626,77.61946793
coefs = (373, 258) # Coefficients in a0/c x**2 + a1/c y**2 + a2/c z**2 = 1
drawCoverage(coefs,latitude,longitude,'b')
plt.show()
I changed the coef calculation to directly use a,b,c in the 3D model and now the axes are proper
# http://stackoverflow.com/questions/7819498/plotting-ellipsoid-with-matplotlib
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(12,12)) # Square figure
ax = fig.add_subplot(111, projection='3d')
def drawCoverage(coefs,latitude,longitude,color):
radius_of_world = 6372.8
# Radii corresponding to the coefficients:
# http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node42.html ??
rx, ry, rz = coefs
# Set of all spherical angles:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
# Postion of the lattitude and logitude on surface of the earth// ellipsoidal earth
x1 = radius_of_world * cos(longitude) * cos(latitude)
y1 = radius_of_world * np.sin(longitude) * np.cos(latitude)
z1 = radius_of_world * np.sin(latitude)
print 'Point location is', x1,y1,z1
# Cartesian coordinates that correspond to the spherical angles:
# (this is the equation of an ellipsoid):
x = rx * np.outer(np.cos(u), np.sin(v))
y = ry * np.outer(np.sin(u), np.sin(v))
z = rz * np.outer(np.ones_like(u), np.cos(v))
#ax.autoscale(enable=True)
# Plot:
ax.plot_wireframe(x , y , z , rstride=4, cstride=4, color='b' )
ax.plot_wireframe(x + 111 , y + 111 , z + 111 , rstride=4, cstride=4, color='g')
#ax.scatter(x , y , z , color='b' )
#ax.scatter(x +111 , y +111 , z +111 , color='g')
#ax.set_xlim3d(0, 500)
#ax.set_ylim3d(0, 500)
#ax.set_zlim3d(0, 500)
# Adjustment of the axes, so that they all have the same span:
#max_radius = .25
#for axis in 'xyz':
# getattr(ax, 'set_{}lim'.format(axis))((-max_radius, max_radius))
latitude,longitude= 13.04738626,77.61946793
coefs = (373, 258, 258) # Coefficients in a0/c x**2 + a1/c y**2 + a2/c z**2 = 1
drawCoverage(coefs,latitude,longitude,'b')
latitude,longitude = 13.04638626, 77.61951605
# Distance between two lat.long is 0.1113 km
# http://www.movable-type.co.uk/scripts/latlong.html
#coefs = (258, 258, 373)
#drawCoverage(coefs,latitude,longitude,'g')
plt.show()
So what I did in the second code snippet is to calculate the distance between the two geographic locations using the Haversine formula ( which give distance as 111 meters approximately. I added this 111 to the second sphere for all x ,y and z points, so as to separate it out and see the overlap of the 'spheres of influence'. Is this approach correct

I guess this is the way
# drawing an ellipsoid - Oblate spheriod to show overlap for two geo points
at two altitudes
# http://stackoverflow.com/questions/7819498/plotting-ellipsoid-with-matplotlib
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(12,12)) # Square figure
ax = fig.add_subplot(111, projection='3d')
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8 # Earth radius in kilometers
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = np.sin(dLat/2)**2 + np.cos(lat1)*np.cos(lat2)*np.sin(dLon/2)**2
c = 2*np.arcsin(np.sqrt(a))
return R * c
def drawCoverage(coefs,horizontal_distance,vertical_distance):
"""Coverage Overalp of two cells sperated by horizotal distance between two geographic co-ordinates and
vertical distance - height
"""
# Radii corresponding to the coefficients:
# http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node42.html ??
rx, ry, rz = coefs
# Set of all spherical angles:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
# Cartesian coordinates that correspond to the spherical angles:
# (this is the equation of an ellipsoid):
x = rx * np.outer(np.cos(u), np.sin(v))
y = ry * np.outer(np.sin(u), np.sin(v))
z = rz * np.outer(np.ones_like(u), np.cos(v))
# Plot:
ax.plot_wireframe(x, y, z , rstride=4, cstride=4, color='b' )
ax.plot_wireframe(x +horizontal_distance, y, z + vertical_distance,rstride=4, cstride=4, color='g')
latitude1,longitude1 = 13.04738626,77.61946793
latitude2,longitude2 = 13.04638626, 77.61951605
dist = haversine(latitude2,longitude2,latitude1,longitude1)
height_in_meters = 258*2
coefs = (373, 258, 258) # 373 major axis, 258 miniir axis - oblate spheroid,roate along x
drawCoverage(coefs,0,height_in_meters)# for visual validity using just height
plt.show()

Related

How to draw sphere with cylinder by formula with matplotlib

I have two formulas:
x^2 + y^2+z^2 = 6
(x-3)^2+y^2=4
So I have to draw this shapes by matplotlib on python.
My solution:
`
import math
import matplotlib.pyplot as plt
from pylab import *
import numpy as np
import matplotlib.patches as patches
from mpl_toolkits.mplot3d import Axes3D
from itertools import product, combinations
import mpl_toolkits.mplot3d.art3d as art3d
def task3():
fig = plt.figure()
ax = plt.axes(projection='3d')
coefs = (1, 1, 1) # Coefficients in a0/c x**2 + a1/c y**2 + a2/c z**2 = 1
# Radii corresponding to the coefficients:
rx, ry, rz = 1 / np.sqrt(coefs)
# Set of all spherical angles:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
# Cartesian coordinates that correspond to the spherical angles:
# (this is the equation of an ellipsoid):
x = rx * np.outer(np.cos(u), np.sin(v))
y = ry * np.outer(np.sin(u), np.sin(v))
z = rz * np.outer(np.ones_like(u), np.cos(v))
ax.plot_surface(x, y, z, rstride=6, cstride=6,
cmap='viridis', edgecolor='none')
# ax.scatter(X, Y, Z, c=Z, cmap='viridis', label="xy")
radius = 0.3
height = 2.4
elevation = -1
resolution = 720
color = 'r'
x_center = 0.7
y_center = -0
a = np.linspace(x_center - radius, x_center + radius, resolution)
b = np.linspace(elevation, elevation + height, resolution)
X, Z = np.meshgrid(a, b)
Y = np.sqrt(radius ** 2 - (X - x_center) ** 2) + y_center # Pythagorean theorem
ax.plot_surface(X, Y, Z, rstride=6, cstride=6,
cmap='viridis', edgecolor='none')
ax.plot_surface(X, (2 * y_center - Y), Z, rstride=6, cstride=6,
cmap='viridis', edgecolor='none')
plt.show()
[![Result. I cant post images, but you can compile result and then you will see that my solution too approximate)
I want to do it correctly

ploting the normal vector to a plane

The normal vector is calculated with the cross product of two vectors on the plane, so it shoud be perpendicular to the plane. But as you can seein the plot the normal vector produced with quiver isn't perpendicular.
Is the calculation of the plane wrong, my normal vector or the way i plot the normal vector?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
points = [[3.2342, 1.8487, -1.8186],
[2.9829, 1.6434, -1.8019],
[3.4247, 1.5550, -1.8093]]
p0, p1, p2 = points
x0, y0, z0 = p0
x1, y1, z1 = p1
x2, y2, z2 = p2
ux, uy, uz = u = [x1-x0, y1-y0, z1-z0] #first vector
vx, vy, vz = v = [x2-x0, y2-y0, z2-z0] #sec vector
u_cross_v = [uy*vz-uz*vy, uz*vx-ux*vz, ux*vy-uy*vx] #cross product
point = np.array(p1)
normal = np.array(u_cross_v)
d = -point.dot(normal)
print('plane equation:\n{:1.4f}x + {:1.4f}y + {:1.4f}z + {:1.4f} = 0'.format(normal[0], normal[1], normal[2], d))
xx, yy = np.meshgrid(range(10), range(10))
z = (-normal[0] * xx - normal[1] * yy - d) * 1. / normal[2]
# plot the surface
plt3d = plt.figure().gca(projection='3d')
plt3d.quiver(x0, y0, z0, normal[0], normal[1], normal[2], color="m")
plt3d.plot_surface(xx, yy, z)
plt3d.set_xlabel("X", color='red', size=18)
plt3d.set_ylabel("Y", color='green', size=18)
plt3d.set_zlabel("Z", color='b', size=18)
plt.show()
Actually, your plot is 100% correct. The scale of your Z axis does not correspond to the same scale on X & Y axis. If you use a function to set the scale correct, you can see that:
...
plt3d.set_zlabel("Z", color='b', size=18)
# insert these lines
ax = plt.gca()
set_axis_equal(ax)
plt.show()
and the corresponding function from this post:
def set_axes_radius(ax, origin, radius):
'''
From StackOverflow question:
https://stackoverflow.com/questions/13685386/
'''
ax.set_xlim3d([origin[0] - radius, origin[0] + radius])
ax.set_ylim3d([origin[1] - radius, origin[1] + radius])
ax.set_zlim3d([origin[2] - radius, origin[2] + radius])
def set_axes_equal(ax, zoom=1.):
'''
Make axes of 3D plot have equal scale so that spheres appear as spheres,
cubes as cubes, etc.. This is one possible solution to Matplotlib's
ax.set_aspect("equal") and ax.axis("equal") not working for 3D.
input:
ax: a matplotlib axis, e.g., as output from plt.gca().
'''
limits = np.array([
ax.get_xlim3d(),
ax.get_ylim3d(),
ax.get_zlim3d(),
])
origin = np.mean(limits, axis=1)
radius = 0.5 * np.max(np.abs(limits[:, 1] - limits[:, 0])) / zoom
set_axes_radius(ax, origin, radius)

Convert plot to a surface plot, matplotlib?

Win 10 x64 Anaconda Python 2.7
I'm plotting an involute spiral onto a Gaussian surface with the following code..
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Spiral parameters
samNum = 1000
spConst = 10.0
t = np.linspace(0, 6*np.pi, samNum)
# Coordinates of involute spiral on xy-plane
coords = np.zeros([samNum, 3])
coords[:,0] = spConst * (np.cos(t) + t * np.sin(t)) # x coord
coords[:,1] = spConst * (np.sin(t) - t * np.cos(t)) # y coord
# Paramters for 2D Gaussian surface
amp = 200
sigma_x = 75.0
sigma_y = 75.0
theta = np.pi
a = np.cos(theta)**2 / (2 * sigma_x**2) + np.sin(theta)**2 / (2 * sigma_y**2)
b = -np.sin(2 * theta) / (4 * sigma_x**2) + np.sin(2 * theta) / (4 * sigma_y**2)
c = np.sin(theta)**2 / (2 * sigma_x**2) + np.cos(theta)**2 / (2 * sigma_y**2)
# z coords of spiral projected onto Gaussian surface
coords[:,2] = amp * np.exp(-(a * coords[:,0]**2 - 2 * b * coords[:,0]*coords[:,1] + c * coords[:,1]**2)) # z coord
# plot 3D spiral
ax.scatter(coords[:,0], coords[:,1], coords[:,2], s=1, c='k')
# plot lines projecting 3D spiral on to the xy-plane
for p in range(samNum):
ax.plot([coords[p,0], coords[p,0]], [coords[p,1], coords[p,1]], [0, coords[p,2]], color='g', linewidth=0.1)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
This gives the following output...
I would like to convert the green ribbon into a continuous surface. I have had a look at parametric surfaces in matplotlib but cant get my head around how to covert this into a surface.
So is this possible? Any pointers appreciated.
In principle you have everything you need already there,
t = np.linspace(0, 6*np.pi, samNum)
T, Z = np.meshgrid(t, [0,1])
X = spConst * (np.cos(T) + T* np.sin(T))
Y = spConst * (np.sin(T) - T * np.cos(T))
gives you the X and Y coordinates, and the upper Z coordinate is obtained via Z[1,:] = coords[:,2].
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Spiral parameters
samNum = 1000
spConst = 10.0
t = np.linspace(0, 6*np.pi, samNum)
T, Z = np.meshgrid(t, [0,1])
X = spConst * (np.cos(T) + T* np.sin(T))
Y = spConst * (np.sin(T) - T * np.cos(T))
# Coordinates of involute spiral on xy-plane
coords = np.zeros([samNum, 3])
coords[:,0] = spConst * (np.cos(t) + t * np.sin(t)) # x coord
coords[:,1] = spConst * (np.sin(t) - t * np.cos(t)) # y coord
# Paramters for 2D Gaussian surface
amp = 200
sigma_x = 75.0
sigma_y = 75.0
theta = np.pi
a = np.cos(theta)**2 / (2 * sigma_x**2) + np.sin(theta)**2 / (2 * sigma_y**2)
b = -np.sin(2 * theta) / (4 * sigma_x**2) + np.sin(2 * theta) / (4 * sigma_y**2)
c = np.sin(theta)**2 / (2 * sigma_x**2) + np.cos(theta)**2 / (2 * sigma_y**2)
# z coords of spiral projected onto Gaussian surface
coords[:,2] = amp * np.exp(-(a * coords[:,0]**2 - 2 * b * coords[:,0]*coords[:,1] + c * coords[:,1]**2)) # z coord
Z[1,:] = coords[:,2]
ax.plot_surface(X,Y,Z)
# plot 3D spiral
ax.scatter(coords[:,0], coords[:,1], coords[:,2], s=1, c='k')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()

python matplotlib: drawing 3D sphere with circumferences

I'm trying to draw a sphere like this one using matplotlib:
but I can't find a way of having a dashed lines on the back and the vertical circumference looks a bit strange
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(12,12), dpi=300)
ax = fig.add_subplot(111, projection='3d')
ax.set_aspect('equal')
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 1 * np.outer(np.cos(u), np.sin(v))
y = 1 * np.outer(np.sin(u), np.sin(v))
z = 1 * np.outer(np.ones(np.size(u)), np.cos(v))
#for i in range(2):
# ax.plot_surface(x+random.randint(-5,5), y+random.randint(-5,5), z+random.randint(-5,5), rstride=4, cstride=4, color='b', linewidth=0, alpha=0.5)
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b', linewidth=0, alpha=0.5)
ax.plot(np.sin(theta),np.cos(u),0,color='k')
ax.plot([0]*100,np.sin(theta),np.cos(u),color='k')
In the example you show, I don't think that the circles can be perpendicular to one another (i.e. one is the equator and one runs through the north pole and south pole). If the horizontal circle is the equator, then the north pole must be somewhere on a vertical line drawn through the center of the yellow circle that represents the sphere. Otherwise, the right side of the equator would look higher or lower than the left. However, the ellipse that represents the polar circle only crosses through that center line at the top and bottom of the yellow circle. Therefore, the north pole is at the top of the sphere, which means that we must be looking straight on the equator, which means it should look like a line, not an ellipse.
Here's some code to reproduce something similar to the figure you posted:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_aspect('equal')
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 1 * np.outer(np.cos(u), np.sin(v))
y = 1 * np.outer(np.sin(u), np.sin(v))
z = 1 * np.outer(np.ones(np.size(u)), np.cos(v))
#for i in range(2):
# ax.plot_surface(x+random.randint(-5,5), y+random.randint(-5,5), z+random.randint(-5,5), rstride=4, cstride=4, color='b', linewidth=0, alpha=0.5)
elev = 10.0
rot = 80.0 / 180 * np.pi
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='b', linewidth=0, alpha=0.5)
#calculate vectors for "vertical" circle
a = np.array([-np.sin(elev / 180 * np.pi), 0, np.cos(elev / 180 * np.pi)])
b = np.array([0, 1, 0])
b = b * np.cos(rot) + np.cross(a, b) * np.sin(rot) + a * np.dot(a, b) * (1 - np.cos(rot))
ax.plot(np.sin(u),np.cos(u),0,color='k', linestyle = 'dashed')
horiz_front = np.linspace(0, np.pi, 100)
ax.plot(np.sin(horiz_front),np.cos(horiz_front),0,color='k')
vert_front = np.linspace(np.pi / 2, 3 * np.pi / 2, 100)
ax.plot(a[0] * np.sin(u) + b[0] * np.cos(u), b[1] * np.cos(u), a[2] * np.sin(u) + b[2] * np.cos(u),color='k', linestyle = 'dashed')
ax.plot(a[0] * np.sin(vert_front) + b[0] * np.cos(vert_front), b[1] * np.cos(vert_front), a[2] * np.sin(vert_front) + b[2] * np.cos(vert_front),color='k')
ax.view_init(elev = elev, azim = 0)
plt.show()

Plotting the temperature distribution on a sphere with python

I have the following problem:
a have N points on a sphere specified by a array x, with x.shape=(N,3). This array contains their cartesian coordinates. Furthermore, at each point, I have a specified temperature. This quantity is saved in an array T, with T.shape=(N,).
Is there any straight forward way to map this temperature distribution into the plane using different colors?
If it simplifies the task, the position can also be given in polar coordinates (\theta,\phi).
To plot your data, you can use Basemap. The only problem is, that both contour and contourf routines needs gridded data. Here is example with naive (and slow) IDW-like interpolation on sphere. Any comments are welcome.
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
def cart2sph(x, y, z):
dxy = np.sqrt(x**2 + y**2)
r = np.sqrt(dxy**2 + z**2)
theta = np.arctan2(y, x)
phi = np.arctan2(z, dxy)
theta, phi = np.rad2deg([theta, phi])
return theta % 360, phi, r
def sph2cart(theta, phi, r=1):
theta, phi = np.deg2rad([theta, phi])
z = r * np.sin(phi)
rcosphi = r * np.cos(phi)
x = rcosphi * np.cos(theta)
y = rcosphi * np.sin(theta)
return x, y, z
# random data
pts = 1 - 2 * np.random.rand(500, 3)
l = np.sqrt(np.sum(pts**2, axis=1))
pts = pts / l[:, np.newaxis]
T = 150 * np.random.rand(500)
# naive IDW-like interpolation on regular grid
theta, phi, r = cart2sph(*pts.T)
nrows, ncols = (90,180)
lon, lat = np.meshgrid(np.linspace(0,360,ncols), np.linspace(-90,90,nrows))
xg,yg,zg = sph2cart(lon,lat)
Ti = np.zeros_like(lon)
for r in range(nrows):
for c in range(ncols):
v = np.array([xg[r,c], yg[r,c], zg[r,c]])
angs = np.arccos(np.dot(pts, v))
idx = np.where(angs == 0)[0]
if idx.any():
Ti[r,c] = T[idx[0]]
else:
idw = 1 / angs**2 / sum(1 / angs**2)
Ti[r,c] = np.sum(T * idw)
# set up map projection
map = Basemap(projection='ortho', lat_0=45, lon_0=15)
# draw lat/lon grid lines every 30 degrees.
map.drawmeridians(np.arange(0, 360, 30))
map.drawparallels(np.arange(-90, 90, 30))
# compute native map projection coordinates of lat/lon grid.
x, y = map(lon, lat)
# contour data over the map.
cs = map.contourf(x, y, Ti, 15)
plt.title('Contours of T')
plt.show()
One way to do this is to set facecolors by mapping your heat data through the colormap.
Here's an example:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
u = np.linspace(0, 2 * np.pi, 80)
v = np.linspace(0, np.pi, 80)
# create the sphere surface
x=10 * np.outer(np.cos(u), np.sin(v))
y=10 * np.outer(np.sin(u), np.sin(v))
z=10 * np.outer(np.ones(np.size(u)), np.cos(v))
# simulate heat pattern (striped)
myheatmap = np.abs(np.sin(y))
ax.plot_surface(x, y, z, cstride=1, rstride=1, facecolors=cm.hot(myheatmap))
plt.show()
Here, my "heatmap" is just stripes along the y-axis, which I made using the function np.abs(np.sin(y)), but anything that goes form 0 to 1 will work (and, of course, it needs to match the shapes on x, etc.

Categories

Resources