We'll keep it simple. [Desmos](https://www.desmos.com/calculator) is one of the best online calculators.
Python is one of the best programming languages. So why no Python API? Who knows.
What we do know is that PyDesmos is the next best thing.
We've made it as easy as possible to interact with Desmos from python:
```python
from PyDesmos import Graph
with Graph('my graph') as G:
f, x = G.f, G.x
f[x] = x ** 2
```
With just these four lines: _an HTML file called "my graph.html" containing a Desmos graph with the expression "f(x)=x^2" already written, is compiled and then automatically opened in your favorite browser!_
Magic? Yes. But that's not all. We've pushed Python's syntax to its limits to make your experience as simple as possible.
Our flexible code incidentally allows many alternatives to `f[x] = x ** 2`, depending on your style / needs:
```python
G.append('f(x)=x^2')
G.define('f(x)', x ** 2) # 'f(x)' is also equivalent to f(x) (yes, without quotes)
G.eq(f(x), x ** 2)
G(f(x), '=', x ** 2)
G(f(x), x ** 2)
G[f(x)] = x ** 2
```
Many more things are made easy. For example, plotting tables:
```python
G.new_table({x: [0, 1, 2], y: [2, 3, 5]}) # where x, y = G.x, G.y, OR
G(x=[0, 1, 2], y=[2, 3, 5])
```
Plotting python functions:
```python
f = lambda x: int(str(x)[::-1])
G.plot_function(f, 0, 100) # OR
G(f, min=0, max=100)
```
Since Desmos uses latex to generate expressions, all latex-friendly [sympy](https://www.sympy.org/en/index.html) expressions get automatically converted.
```python
import sympy as sp
with Graph('my graph') as G:
x, y = G.x, G.y
G.le(sp.factorial(x + y), sp.sin(x - y)) # appends the expression "(x+y)! <= sin(x-y)"
```
Sliders and greek letter support:
```python
G(alpha=0, min=0, max=2 * G.pi, step=G.pi / 2) # appends the constant "α=0" with respective bounds
```
Yet another way to append expressions:
```python
G | sympy.sin(2 * G.x) # appends the expression "sin(2x)"
```
Points:
```python
G(p=(0,0)) # appends the point "p=(0,0)"
```
Prime-notation:
```python
G | (f^1)(x) # appends the expression "f'(x)", where f, x = G.f, x.f
```
Subscript notation:
```python
G(c[0], 42) # appends the expression "c_{0}=42", where c = G.c
```
...
Alright, I'm sure you get it. PyDesmos is awesome. But one last thing. All of these methods have additional (optional) kwargs for absolute customization, such as color, line thickness, etc.
You may read about them [here](https://www.desmos.com/api/v1.7/docs/index.html#document-manipulating-expressions), under "expression_state Name and Values". For example,
```python
G(y=G.x ** 2, color='#FF0000') # appends the expression "y=x^2" with color #FF0000.
```
Happy PyDesmos-ing!
---
**New:** To plot a sequence from the [OEIS](https://oeis.org/):
```python
G.plot_oeis('A000001') # optional max_terms parameter
```
Or to just get a dictionary:
```python
A000001 = oeis('A000001') # returns {0: 0, 1: 1, ...}
```
Query support:
```python
G.plot_oeis('the prime numbers') # OR
G.plot_oeis([2, 3, 5, 7])
```
Related method with the OEIS
```python
oeis_query('the prime numbers') # returns a list of the first few most relevant sequence ids
```
Change Log
==========
0.0.1 (12/04/2023)
-------------------
- First Release
0.1.0 (12/04/2023)
-------------------
- Entered Alpha
- Major code revisions
- improved README.md
0.1.1 (13/04/2023)
-------------------
- Minor tweaks (mostly to README.md)
- Fixed optional kwargs with tables
0.1.2 (13/04/2023)
-------------------
- Added simple OEIS integration
- Added support for all greek letters
0.1.3 (13/04/2023)
-------------------
- Increased OEIS support. (allows for querying the most relevant sequences based off a list of terms or keywords)
Raw data
{
"_id": null,
"home_page": "",
"name": "PyDesmos",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "math,graph,desmos,graphing software,html,sympy,api,oeis",
"author": "Lyam Boylan",
"author_email": "lyamboylan@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e7/ce/cc986d5e84483fff6d00e60cc002acb7ac7f0c20ddd10d509e23fdba9e50/PyDesmos-0.1.3.tar.gz",
"platform": null,
"description": "We'll keep it simple. [Desmos](https://www.desmos.com/calculator) is one of the best online calculators.\r\nPython is one of the best programming languages. So why no Python API? Who knows.\r\nWhat we do know is that PyDesmos is the next best thing.\r\n\r\nWe've made it as easy as possible to interact with Desmos from python:\r\n```python\r\nfrom PyDesmos import Graph\r\nwith Graph('my graph') as G:\r\n f, x = G.f, G.x\r\n f[x] = x ** 2\r\n```\r\nWith just these four lines: _an HTML file called \"my graph.html\" containing a Desmos graph with the expression \"f(x)=x^2\" already written, is compiled and then automatically opened in your favorite browser!_\r\n\r\nMagic? Yes. But that's not all. We've pushed Python's syntax to its limits to make your experience as simple as possible.\r\nOur flexible code incidentally allows many alternatives to `f[x] = x ** 2`, depending on your style / needs:\r\n\r\n```python\r\nG.append('f(x)=x^2')\r\nG.define('f(x)', x ** 2) # 'f(x)' is also equivalent to f(x) (yes, without quotes)\r\nG.eq(f(x), x ** 2)\r\nG(f(x), '=', x ** 2)\r\nG(f(x), x ** 2)\r\nG[f(x)] = x ** 2\r\n```\r\n\r\nMany more things are made easy. For example, plotting tables:\r\n\r\n```python\r\nG.new_table({x: [0, 1, 2], y: [2, 3, 5]}) # where x, y = G.x, G.y, OR\r\nG(x=[0, 1, 2], y=[2, 3, 5])\r\n```\r\n\r\nPlotting python functions:\r\n```python\r\nf = lambda x: int(str(x)[::-1])\r\nG.plot_function(f, 0, 100) # OR\r\nG(f, min=0, max=100)\r\n```\r\n\r\nSince Desmos uses latex to generate expressions, all latex-friendly [sympy](https://www.sympy.org/en/index.html) expressions get automatically converted.\r\n```python\r\nimport sympy as sp\r\nwith Graph('my graph') as G:\r\n x, y = G.x, G.y\r\n G.le(sp.factorial(x + y), sp.sin(x - y)) # appends the expression \"(x+y)! <= sin(x-y)\"\r\n```\r\nSliders and greek letter support:\r\n```python\r\nG(alpha=0, min=0, max=2 * G.pi, step=G.pi / 2) # appends the constant \"\u03b1=0\" with respective bounds\r\n```\r\nYet another way to append expressions:\r\n```python\r\nG | sympy.sin(2 * G.x) # appends the expression \"sin(2x)\"\r\n```\r\nPoints:\r\n```python\r\nG(p=(0,0)) # appends the point \"p=(0,0)\"\r\n```\r\nPrime-notation:\r\n```python\r\nG | (f^1)(x) # appends the expression \"f'(x)\", where f, x = G.f, x.f\r\n```\r\nSubscript notation:\r\n```python\r\nG(c[0], 42) # appends the expression \"c_{0}=42\", where c = G.c\r\n```\r\n...\r\n\r\nAlright, I'm sure you get it. PyDesmos is awesome. But one last thing. All of these methods have additional (optional) kwargs for absolute customization, such as color, line thickness, etc.\r\nYou may read about them [here](https://www.desmos.com/api/v1.7/docs/index.html#document-manipulating-expressions), under \"expression_state Name and Values\". For example,\r\n```python\r\nG(y=G.x ** 2, color='#FF0000') # appends the expression \"y=x^2\" with color #FF0000.\r\n```\r\nHappy PyDesmos-ing!\r\n\r\n---\r\n\r\n**New:** To plot a sequence from the [OEIS](https://oeis.org/):\r\n```python\r\nG.plot_oeis('A000001') # optional max_terms parameter\r\n```\r\nOr to just get a dictionary:\r\n```python\r\nA000001 = oeis('A000001') # returns {0: 0, 1: 1, ...}\r\n```\r\nQuery support:\r\n```python\r\nG.plot_oeis('the prime numbers') # OR\r\nG.plot_oeis([2, 3, 5, 7])\r\n```\r\nRelated method with the OEIS\r\n```python\r\noeis_query('the prime numbers') # returns a list of the first few most relevant sequence ids\r\n```\r\n\r\nChange Log\r\n==========\r\n\r\n0.0.1 (12/04/2023)\r\n-------------------\r\n- First Release\r\n\r\n0.1.0 (12/04/2023)\r\n-------------------\r\n- Entered Alpha\r\n- Major code revisions\r\n- improved README.md\r\n\r\n0.1.1 (13/04/2023)\r\n-------------------\r\n- Minor tweaks (mostly to README.md)\r\n- Fixed optional kwargs with tables\r\n\r\n0.1.2 (13/04/2023)\r\n-------------------\r\n- Added simple OEIS integration\r\n- Added support for all greek letters\r\n\r\n0.1.3 (13/04/2023)\r\n-------------------\r\n- Increased OEIS support. (allows for querying the most relevant sequences based off a list of terms or keywords)\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An easy-to-use Python to Desmos graph HTML compiler via the Desmos API (with OEIS support).",
"version": "0.1.3",
"split_keywords": [
"math",
"graph",
"desmos",
"graphing software",
"html",
"sympy",
"api",
"oeis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e7cecc986d5e84483fff6d00e60cc002acb7ac7f0c20ddd10d509e23fdba9e50",
"md5": "4c8abdad49ad20b9be31387b84659d98",
"sha256": "f22d353430fe87118a84da105437cdeb5e292ba875b062d9978c3a639f3e0d6c"
},
"downloads": -1,
"filename": "PyDesmos-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "4c8abdad49ad20b9be31387b84659d98",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14101,
"upload_time": "2023-04-14T00:33:38",
"upload_time_iso_8601": "2023-04-14T00:33:38.636445Z",
"url": "https://files.pythonhosted.org/packages/e7/ce/cc986d5e84483fff6d00e60cc002acb7ac7f0c20ddd10d509e23fdba9e50/PyDesmos-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-14 00:33:38",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "pydesmos"
}