1
This repository has been archived on 2021-11-25. You can view files and clone it, but cannot push or open issues or pull requests.
Project_Steam_Tracker/graphs.py

36 lines
755 B
Python

from matplotlib.backends.backend_svg import FigureCanvasSVG
from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.figure import Figure
import numpy as np
import random
import io
import math
def random_plot():
fig = Figure()
axis = fig.add_subplot(1, 1, 1)
randint = random.randint(1, 50)
x = np.arange(randint, random.randint(randint, randint+50), 0.05)
y = np.tan(math.pi*x)
axis.plot(x, y)
output = io.BytesIO()
FigureCanvasSVG(fig).print_svg(output)
return output.getvalue()
def plot_xy(x, y):
fig = Figure(figsize=(32, 18))
axis = fig.add_subplot(1, 1, 1)
axis.plot(x, y)
output = io.BytesIO()
FigureCanvasAgg(fig).print_png(output)
return output.getvalue()