-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathexample.py
More file actions
42 lines (27 loc) · 858 Bytes
/
example.py
File metadata and controls
42 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import asyncio
from dotenv import load_dotenv
from e2b_code_interpreter import Sandbox
load_dotenv()
code = """
import matplotlib.pyplot as plt
import numpy as np
# Step 1: Define the data for the pie chart
categories = ["No", "No, in blue"]
sizes = [90, 10]
# Step 2: Create the figure and axis objects
fig, ax = plt.subplots(figsize=(8, 8))
plt.xlabel("x")
plt.ylabel("y")
# Step 3: Create the pie chart
ax.pie(sizes, labels=categories, autopct='%1.1f%%', startangle=90, colors=plt.cm.Pastel1.colors[:len(categories)])
# Step 4: Add title and legend
ax.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle
plt.title('Will I wake up early tomorrow?')
# Step 5: Show the plot
plt.show()
"""
async def run():
sbx = Sandbox.create(timeout=60)
e = sbx.run_code(code)
print(e.results[0].chart)
asyncio.run(run())