Skip to content

Instantly share code, notes, and snippets.

@basnijholt
Created May 12, 2021 09:00
Show Gist options
  • Save basnijholt/d87d691237e0f1ec87745c95e581a4a8 to your computer and use it in GitHub Desktop.
Save basnijholt/d87d691237e0f1ec87745c95e581a4a8 to your computer and use it in GitHub Desktop.
import matplotlib.tri as mtri
from matplotlib import pyplot as plt
def plot_loss(learner, cmap="viridis", xy_size=(10, 10)):
fig, ax = plt.subplots(figsize=xy_size)
x_size, y_size = xy_size
ip = learner.ip()
zs = learner.loss_per_triangle(ip)
tri = ip.tri
xs, ys = tri.points.T
x_size, y_size = xy_size
triang = mtri.Triangulation(x_size * xs, y_size * ys, triangles=tri.vertices)
ax.triplot(triang, c="k", lw=0.3, alpha=1, zorder=2), (ip.values, triang)
im = ax.tripcolor(triang, zs.flatten(), zorder=0, cmap=cmap)
plt.colorbar(im)
@basnijholt
Copy link
Author

Example result:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment