mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#1791 Update docs for Python integration with Mermaid
This commit is contained in:
parent
2e7452f067
commit
ec418f98c0
@ -34,3 +34,35 @@ https://codepen.io/janzeteachesit/pen/OWWZKN
|
||||
## Mermaid with Text Area
|
||||
|
||||
https://codepen.io/Ryuno-Ki/pen/LNxwgR
|
||||
|
||||
## Python Integration with mermaid-js
|
||||
Here's an example of python integration with mermaid-js which uses the mermaid.ink service.
|
||||
This is also working with colab and jupyter lab notebooks.
|
||||
|
||||
```python
|
||||
import base64
|
||||
|
||||
graphbytes = graph.encode("ascii")
|
||||
|
||||
graph = """
|
||||
graph LR;
|
||||
A--> B & C & D;
|
||||
B--> A & E;
|
||||
C--> A & E;
|
||||
D--> A & E;
|
||||
E--> B & C & D;
|
||||
"""
|
||||
|
||||
base64_bytes = base64.b64encode(graphbytes)
|
||||
base64_string = base64_bytes.decode("ascii")
|
||||
|
||||
import requests, io
|
||||
from PIL import Image
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
img = Image.open(io.BytesIO(requests.get('https://mermaid.ink/img/' + base64_string).content))
|
||||
plt.imshow(img)
|
||||
```
|
||||
**Output**
|
||||
|
||||
![image](img/python-mermaid-integration.png)
|
||||
|
BIN
docs/img/python-mermaid-integration.png
Normal file
BIN
docs/img/python-mermaid-integration.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Loading…
x
Reference in New Issue
Block a user