mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 14:59:53 +02:00
Fix issue in python sample source in Tutorials.md
Updated python sample source in Tutorials to make it work. Before this change problem was: ``` C:\Users\user>python mermaid.py Traceback (most recent call last): File "mermaid.py", line 3, in <module> graphbytes = graph.encode("ascii") NameError: name 'graph' is not defined ```
This commit is contained in:
@@ -39,8 +39,9 @@ This is also working with colab and jupyter lab notebooks.
|
||||
|
||||
```python
|
||||
import base64
|
||||
|
||||
graphbytes = graph.encode("ascii")
|
||||
import requests, io
|
||||
from PIL import Image
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
graph = """
|
||||
graph LR;
|
||||
@@ -51,16 +52,13 @@ graph LR;
|
||||
E--> B & C & D;
|
||||
"""
|
||||
|
||||
graphbytes = graph.encode("ascii")
|
||||
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**
|
||||
|
||||

|
||||
|
Reference in New Issue
Block a user