Gráficos de coordenadas no estructuradas#
Ultima modificación: Feb 04, 2024 | YouTube
[1]:
import matplotlib.pyplot as plt
import numpy as np
[2]:
np.random.seed(1)
x = np.random.uniform(-3, 3, 256)
y = np.random.uniform(-3, 3, 256)
z = (1 - x / 2 + x**5 + y**3) * np.exp(-(x**2) - y**2)
levels = np.linspace(z.min(), z.max(), 7)
[3]:
#
# tricontour(x, y, z)
#
fig, ax = plt.subplots(figsize=(3.5, 3.5))
ax.plot(x, y, "o", markersize=2, color="lightgrey")
ax.tricontour(x, y, z, levels=levels)
ax.set(xlim=(-3, 3), ylim=(-3, 3))
plt.show()

[4]:
#
# tricontourf(x, y, z)
#
fig, ax = plt.subplots(figsize=(3.5, 3.5))
ax.plot(x, y, "o", markersize=2, color="grey")
ax.tricontourf(x, y, z, levels=levels)
ax.set(xlim=(-3, 3), ylim=(-3, 3))
plt.show()

[5]:
#
# tripcolor(x, y, z)
#
fig, ax = plt.subplots(figsize=(3.5, 3.5))
ax.plot(x, y, "o", markersize=2, color="grey")
ax.tripcolor(x, y, z)
ax.set(xlim=(-3, 3), ylim=(-3, 3))
plt.show()

[6]:
#
# triplot(x, y)
#
fig, ax = plt.subplots(figsize=(3.5, 3.5))
ax.triplot(x, y)
ax.set(xlim=(-3, 3), ylim=(-3, 3))
plt.show()
