Skip to content

Instantly share code, notes, and snippets.

@mateusmb
Created May 2, 2022 19:55
Show Gist options
  • Save mateusmb/e3500b99f268c9baeec710240782e1f5 to your computer and use it in GitHub Desktop.
Save mateusmb/e3500b99f268c9baeec710240782e1f5 to your computer and use it in GitHub Desktop.
Pyscript test with matplotlib
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- numpy
- matplotlib
</py-env>
</head>
<body>
<h1>Pyscript + Matplotlib</h1>
<div id="plot"></div>
<py-script output="plot">
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import numpy as np
np.random.seed(3)
x = np.random.random(100)
y = np.random.random(100)
z = np.random.random(100)
fig = plt.figure(figsize=(9,6))
ax = plt.axes(projection='3d')
ax = ax.scatter3D(x, y, z, color='purple')
fig
</py-script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment