1. Home
  2. /
  3. Pyscript
  4. /
  5. Simple Plot Example

Simple Plot Example - Pyscript Typing CST Test

Loading…

Simple Plot Example — Pyscript Code

Uses matplotlib to create a simple plot directly in PyScript.

<!DOCTYPE html>
<html>
<head>
	<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
	<py-script>
		import matplotlib.pyplot as plt
		plt.plot([1,2,3], [4,5,6])
		plt.show()
	</py-script>
</body>
</html>

Pyscript Language Guide

PyScript is a framework that allows running Python code directly in web browsers using HTML and JavaScript integration. It bridges Python with the web platform, enabling interactive applications without traditional backend setup.

Primary Use Cases

  • ▸Embedding Python code in web pages for interactivity
  • ▸Educational platforms teaching Python in the browser
  • ▸Interactive data visualizations with Python libraries
  • ▸Prototyping web apps quickly using Python
  • ▸Combining Python and JavaScript for hybrid applications

Notable Features

  • ▸Write Python directly in HTML with `<py-script>` tags
  • ▸Access JavaScript objects and browser APIs from Python
  • ▸Support for popular Python libraries like NumPy, Pandas, and Matplotlib
  • ▸Live code execution in browser without server
  • ▸Integration with Pyodide for WebAssembly-based Python runtime

Origin & Creator

Created by Anaconda, Inc., first announced in 2022, inspired by the desire to make Python a first-class citizen for web development alongside JavaScript.

Industrial Note

Used in education, prototyping, and interactive demos; suitable for web-based Python experimentation but not yet a replacement for full-scale web frameworks.

More Pyscript Typing Exercises

Hello World in PyScriptPyScript Variables ExamplePyScript If Statement ExamplePyScript Loop ExamplePyScript Function ExamplePyScript Input ExamplePyScript Math ExamplePyScript List ExamplePyScript Conditional Loop Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher