mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC: Edit: Add plot display mode 'time' and 'date'.
This commit is contained in:
1 parent
7a7e714ea4
commit
67af95cb40
2 files changed
+22
-10
No files matched your search
@@ -14,13 +14,16 @@ from View.BoundaryCondition.Edit.translate import *
|
|||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class Plot(APlot):
|
class Plot(APlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None):
|
def __init__(self, canvas=None, data=None,
|
||||||
|
mode = "time", toolbar=None):
|
||||||
super(Plot, self).__init__(
|
super(Plot, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
data=data,
|
data=data,
|
||||||
toolbar=toolbar
|
toolbar=toolbar
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._mode = mode
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
t0 = datetime.fromtimestamp(0)
|
t0 = datetime.fromtimestamp(0)
|
||||||
nb = len(self.data.data)
|
nb = len(self.data.data)
|
||||||
@@ -36,16 +39,24 @@ class Plot(APlot):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
xx = list(map(lambda v: v[0], fx))
|
xx = list(map(lambda v: v[0], fx))
|
||||||
xt = list(
|
if self._mode == "time":
|
||||||
map(
|
xt = list(
|
||||||
lambda v: str(
|
map(
|
||||||
datetime.fromtimestamp(v[0]) - t0
|
lambda v: str(
|
||||||
).split(",")[0]\
|
datetime.fromtimestamp(v[0]) - t0
|
||||||
.replace("days", _translate("BoundaryCondition", "days"))\
|
).split(",")[0]\
|
||||||
.replace("day", _translate("BoundaryCondition", "day")),
|
.replace("days", _translate("BoundaryCondition", "days"))\
|
||||||
fx
|
.replace("day", _translate("BoundaryCondition", "day")),
|
||||||
|
fx
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
xt = list(
|
||||||
|
map(
|
||||||
|
lambda v: str(datetime.fromtimestamp(v[0]).date()),
|
||||||
|
fx
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||||||
self.plot = Plot(
|
self.plot = Plot(
|
||||||
canvas = self.canvas,
|
canvas = self.canvas,
|
||||||
data = self._data,
|
data = self._data,
|
||||||
|
mode = self._study.time_system,
|
||||||
)
|
)
|
||||||
self.plot.draw()
|
self.plot.draw()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user