|
19 | 19 | from importlib.metadata import version |
20 | 20 | import subprocess |
21 | 21 | from pathlib import Path |
22 | | -import itertools as it |
23 | 22 | import logging |
24 | 23 | from collections import defaultdict |
25 | 24 | import numpy as np |
|
106 | 105 | (255, 0, 125), (255, 125, 0), (0, 125, 255), (0, 255, 125), (125, 0, 255), (125, 255, 0), (0, 255, 0)] |
107 | 106 | thickness = 1 |
108 | 107 |
|
109 | | -## CLASSES |
110 | | -class plotWindow(): |
111 | | - ''' |
112 | | - Display several figures in tabs |
113 | | - Taken from https://github.com/superjax/plotWindow/blob/master/plotWindow.py |
114 | | -
|
115 | | - USAGE: |
116 | | - pw = plotWindow() |
117 | | - f = plt.figure() |
118 | | - plt.plot(x1, y1) |
119 | | - pw.addPlot("1", f) |
120 | | - f = plt.figure() |
121 | | - plt.plot(x2, y2) |
122 | | - pw.addPlot("2", f) |
123 | | - ''' |
124 | | - def __init__(self, parent=None): |
125 | | - self.app = QApplication.instance() |
126 | | - if not self.app: |
127 | | - self.app = QApplication(sys.argv) |
128 | | - self.MainWindow = QMainWindow() |
129 | | - self.MainWindow.setWindowTitle("Multitabs figure") |
130 | | - self.canvases = [] |
131 | | - self.figure_handles = [] |
132 | | - self.toolbar_handles = [] |
133 | | - self.tab_handles = [] |
134 | | - self.current_window = -1 |
135 | | - self.tabs = QTabWidget() |
136 | | - self.MainWindow.setCentralWidget(self.tabs) |
137 | | - self.MainWindow.resize(1280, 720) |
138 | | - self.MainWindow.show() |
139 | | - |
140 | | - def addPlot(self, title, figure): |
141 | | - new_tab = QWidget() |
142 | | - layout = QVBoxLayout() |
143 | | - new_tab.setLayout(layout) |
144 | | - |
145 | | - figure.subplots_adjust(left=0.1, right=0.99, bottom=0.1, top=0.91, wspace=0.2, hspace=0.2) |
146 | | - new_canvas = FigureCanvas(figure) |
147 | | - new_toolbar = NavigationToolbar(new_canvas, new_tab) |
148 | | - |
149 | | - layout.addWidget(new_canvas) |
150 | | - layout.addWidget(new_toolbar) |
151 | | - self.tabs.addTab(new_tab, title) |
152 | | - |
153 | | - self.toolbar_handles.append(new_toolbar) |
154 | | - self.canvases.append(new_canvas) |
155 | | - self.figure_handles.append(figure) |
156 | | - self.tab_handles.append(new_tab) |
157 | | - |
158 | | - def show(self): |
159 | | - self.app.exec_() |
160 | | - |
161 | 108 | ## FUNCTIONS |
162 | 109 | def to_dict(d): |
163 | 110 | ''' |
|
0 commit comments