Skip to content

Instantly share code, notes, and snippets.

@trashhalo
Last active September 19, 2021 20:16
Show Gist options
  • Save trashhalo/bf0b5d54245748f48b6a2e58c1498a41 to your computer and use it in GitHub Desktop.
Save trashhalo/bf0b5d54245748f48b6a2e58c1498a41 to your computer and use it in GitHub Desktop.
Python plotting demo in astro
#!/usr/bin/env python
import sys
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
image_format = 'svg'
fig.savefig(sys.stdout, format=image_format, dpi=1200)
---
import { Command } from "astro-command";
---
<h1> Python plot demo </h1>
<Command caller={import.meta.url} command="./Component.py" sendProps={false} />
@trashhalo
Copy link
Author

Screenshot 2021-09-19 144501

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