Results: Plot: Fill between in KPC and fill water zone in XY.

mesh
Pierre-Antoine Rouby 2023-08-09 17:21:59 +02:00
parent 24bc373827
commit 6356bab320
2 changed files with 36 additions and 12 deletions

View File

@ -90,6 +90,11 @@ class PlotKPC(APlot):
color='b', color='b',
) )
self.canvas.axes.fill_between(
kp, z_min, water_z,
color='blue', alpha=0.5, interpolate=True
)
self.canvas.figure.tight_layout() self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle() self.canvas.figure.canvas.draw_idle()
if self.toolbar is not None: if self.toolbar is not None:

View File

@ -16,6 +16,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging
from functools import reduce from functools import reduce
from tools import timer, trace from tools import timer, trace
@ -27,6 +29,8 @@ from PyQt5.QtCore import (
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
logger = logging.getLogger()
class PlotXY(APlot): class PlotXY(APlot):
def __init__(self, canvas=None, results=None, def __init__(self, canvas=None, results=None,
reach_id=0, profile_id=0, reach_id=0, profile_id=0,
@ -109,7 +113,23 @@ class PlotXY(APlot):
for x, y in zip(x_complete, y_complete) for x, y in zip(x_complete, y_complete)
] ]
if self.display_current:
# Current profile
profile = reach.profile(self._current_profile_id).geometry
self.plot_selected, = self.canvas.axes.plot(
profile.x(),
profile.y(),
lw=1., markersize=3,
marker='+', color="b"
)
self.plot_selected.set_visible(False)
# Display point under water # Display point under water
poly_l_x = []
poly_l_y = []
poly_r_x = []
poly_r_y = []
for profile in reach.profiles: for profile in reach.profiles:
water_z = profile.get_ts_key( water_z = profile.get_ts_key(
self._current_timestamp, "Z" self._current_timestamp, "Z"
@ -125,24 +145,23 @@ class PlotXY(APlot):
([], []) ([], [])
) )
poly_l_x.append(x[0])
poly_l_y.append(y[0])
poly_r_x.append(x[-1])
poly_r_y.append(y[-1])
self.canvas.axes.plot( self.canvas.axes.plot(
x, y, lw=1., x, y, lw=1.,
color='b', color='b',
markersize=4, markersize=1,
marker='o' marker='o'
) )
if self.display_current: poly_x = poly_l_x + list(reversed(poly_r_x)) + [poly_l_x[0]]
# Current profile poly_y = poly_l_y + list(reversed(poly_r_y)) + [poly_l_y[0]]
profile = reach.profile(self._current_profile_id).geometry # FIXME: Fill do not works ? (tmp fix: use plot)
self.canvas.axes.fill(poly_x, poly_y, color='blue', alpha=0.5)
self.plot_selected, = self.canvas.axes.plot( self.canvas.axes.plot(poly_x, poly_y, color='blue', alpha=0.5)
profile.x(),
profile.y(),
lw=1., markersize=3,
marker='+', color="b"
)
self.plot_selected.set_visible(False)
self.canvas.axes.autoscale_view(True, True, True) self.canvas.axes.autoscale_view(True, True, True)
self.canvas.axes.autoscale() self.canvas.axes.autoscale()