Skip to content

Instantly share code, notes, and snippets.

@ydm
Created December 23, 2023 17:58
Show Gist options
  • Save ydm/477d27ac5d9d9a983fdf4924ed111ceb to your computer and use it in GitHub Desktop.
Save ydm/477d27ac5d9d9a983fdf4924ed111ceb to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import numpy as np
from matplotlib import cm
from matplotlib import pyplot as plt
xs, ys = np.meshgrid(
np.linspace(1/1000, 1, 999),
np.linspace(1/1000, 1, 999),
)
zs = []
for x, y in zip(xs.ravel(), ys.ravel()):
z = (x - y) / (x + y)
zs.append(z)
zs = np.array(zs).reshape(xs.shape)
fig = plt.figure(figsize=(24, 24))
ax = plt.axes(projection='3d')
ax.plot_surface(xs, ys, zs, cmap=cm.coolwarm_r)
ax.set_xlabel('First')
ax.set_ylabel('Second')
ax.set_zlabel('Difference')
ax.view_init(30, 220)
plt.savefig('3d.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment