-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPltInterface.py
More file actions
45 lines (35 loc) · 1.17 KB
/
Copy pathPltInterface.py
File metadata and controls
45 lines (35 loc) · 1.17 KB
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
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 21 21:17:02 2020
@author: gerard
"""
import matplotlib
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import tkinter as Tk
import matplotlib.pyplot as plt
class Plot:
"""
Plot Interface:
This object is used to combine matplotlib plots with the Tkinter interfice
"""
def __init__(self, curveList, starList):
self.master = Tk.Tk()
self.master.resizable(width=False, height=False)
self.plot(curveList, starList)
def plot(self, curveList, starList):
colors = plt.rcParams["axes.prop_cycle"]()
fig = Figure(figsize=(10,10))
n = len(curveList)
starList = [str(x) for x in starList]
for i in range(n):
c = next(colors)["color"]
plotfig = fig.add_subplot((n//2)+1, 2, i + 1)
plotfig.plot(curveList[i],label=starList[i],color=c)
fig.legend()
canvas = FigureCanvasTkAgg(fig, master=self.master)
canvas.get_tk_widget().pack()
canvas.draw()
return None