plot style creation happens in MDISub*Plot; made style mandatory argument to PlotDescription.make_plot

This commit is contained in:
2023-01-08 18:41:36 +01:00
parent 2b019fa1db
commit df621020ac
2 changed files with 6 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import pyqtgraph as pg
from .mdisubwin import MDISubWindow
from ..theme import pg_plot_style, pg_plot_style_cycler
class MDISubPlot(MDISubWindow):
@ -8,15 +8,14 @@ class MDISubPlot(MDISubWindow):
def __init__(self, title, desc, *args, **kwargs):
super().__init__(title, *args, **kwargs)
style = pg_plot_style()
plt = pg.PlotWidget()
self.plot = desc.make_plot(plt)
self.plot = desc.make_plot(plt, style)
self.setWidget(plt)
from ..theme import pg_plot_style_cycler
class MDISubMultiPlot(MDISubWindow):
def __init__(self, titles, descs, *args, **kwargs):
@ -26,7 +25,7 @@ class MDISubMultiPlot(MDISubWindow):
psc = pg_plot_style_cycler()
plt = pg.PlotWidget()
self.plots = [d.make_plot(plt, style=s) for d, s in zip(descs, psc)]
self.plots = [d.make_plot(plt, s) for d, s in zip(descs, psc)]
self.setWidget(plt)

View File

@ -1,5 +1,3 @@
from .theme import pg_plot_style
class PlotDescription:
@ -9,7 +7,6 @@ class PlotDescription:
self.ylabel = ylabel
self.xs = []
self.ys = []
self.style = pg_plot_style()
@property
@ -23,9 +20,7 @@ class PlotDescription:
self.ys.append(y)
def make_plot(self, plotwidget, style=None):
style = style or self.style
def make_plot(self, plotwidget, style):
res = plotwidget.plot(self.xs, self.ys, **style)
if self.title: