I want to create heat maps of a scalar field in SAGE. Here is equivalent 
code in Matplotlib that does the job along with the resulting output. The 
matplotlib code uses the .pcolormesh function. Is there an equivalent in 
SAGE? 

The closest I can see are the functions that create contour plots as given 
here 
<https://doc.sagemath.org/html/en/reference/plotting/sage/plot/contour_plot.html>,
 
but I don’t want the discrete bands that are created in those plots; for 
contour plots that is of course natural because you want to see the shapes 
of the individual level curves. 

However, I specifically want the continuous smearing as outputted by the 
Matplotlib code below, which gives a “heat-map” of the 2D scalar function.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm 

fig,ax = plt.subplots()
L = 3
x    = np.linspace(-L, L, 100) 
y    = np.linspace(-L, L, 100) 
X, Y = np.meshgrid(x, y)
Z    = np.cos(X) - 2*Y 

z_min, z_max = -np.abs(Z).max(), np.abs(Z).max()
c= ax.pcolormesh(X, Y, Z, cmap='RdBu', vmin=z_min, vmax=z_max) 
fig.colorbar(c, ax=ax)

ax.set_aspect(1.0)
ax.set_title("Heat map of scalar field",fontsize=20)
fig.set_size_inches((10,10))
plt.show()



Thanks!

Gaurish
​

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/b4784fd6-22a7-4f2d-b4ae-26631956135cn%40googlegroups.com.

Reply via email to