mirror of https://gitlab.com/pamhyr/pamhyr2
Plot: Add a default colors set and delete geo:plot_xy dependence on geo:plot_ac.
parent
30d76da32f
commit
c58dc5785a
|
|
@ -32,7 +32,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
class PlotAC(PamhyrPlot):
|
class PlotAC(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||||
plot_xy=None, parent=None):
|
parent=None):
|
||||||
super(PlotAC, self).__init__(
|
super(PlotAC, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
trad=trad,
|
trad=trad,
|
||||||
|
|
@ -46,8 +46,6 @@ class PlotAC(PamhyrPlot):
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = True
|
||||||
|
|
||||||
self.plot_xy = plot_xy
|
|
||||||
|
|
||||||
self.label_x = _translate(
|
self.label_x = _translate(
|
||||||
"Geometry", "Transverse abscissa (m)"
|
"Geometry", "Transverse abscissa (m)"
|
||||||
)
|
)
|
||||||
|
|
@ -67,18 +65,9 @@ class PlotAC(PamhyrPlot):
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.next_plot_selected = None
|
self.next_plot_selected = None
|
||||||
|
|
||||||
def get_line_gl_colors(self, line_2d):
|
|
||||||
colors = []
|
|
||||||
|
|
||||||
for line in line_2d:
|
|
||||||
colors.append(line[0].get_color())
|
|
||||||
|
|
||||||
return colors
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.canvas.axes.cla()
|
self.init_axes()
|
||||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
|
||||||
|
|
||||||
if self.data.number_profiles == 0:
|
if self.data.number_profiles == 0:
|
||||||
return
|
return
|
||||||
|
|
@ -140,8 +129,7 @@ class PlotAC(PamhyrPlot):
|
||||||
lcomplete = list(self.complete_gl)
|
lcomplete = list(self.complete_gl)
|
||||||
lincomplete = list(self.incomplete_gl)
|
lincomplete = list(self.incomplete_gl)
|
||||||
|
|
||||||
line_2d = self.plot_xy.line_gl
|
self.color_complete_gl = self.colors
|
||||||
self.color_complete_gl = self.get_line_gl_colors(line_2d)
|
|
||||||
self.color_incomplete_gl = 2 * ["grey"]
|
self.color_incomplete_gl = 2 * ["grey"]
|
||||||
|
|
||||||
x_gl_complete = []
|
x_gl_complete = []
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ class PlotKPZ(PamhyrPlot):
|
||||||
|
|
||||||
def draw_gl(self):
|
def draw_gl(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
|
||||||
|
ind = 0
|
||||||
self.line_kp_zgl = []
|
self.line_kp_zgl = []
|
||||||
for z in self.data.get_guidelines_z():
|
for z in self.data.get_guidelines_z():
|
||||||
# Is incomplete guideline?
|
# Is incomplete guideline?
|
||||||
|
|
@ -172,9 +174,10 @@ class PlotKPZ(PamhyrPlot):
|
||||||
|
|
||||||
self.line_kp_zgl.append(
|
self.line_kp_zgl.append(
|
||||||
self.canvas.axes.plot(
|
self.canvas.axes.plot(
|
||||||
kp, z, lw=1.
|
kp, z, lw=1., color=self.colors[ind]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
ind += 1
|
||||||
|
|
||||||
def draw_bottom(self):
|
def draw_bottom(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,14 @@ class PlotXY(PamhyrPlot):
|
||||||
x_complete = self.data.get_guidelines_x()
|
x_complete = self.data.get_guidelines_x()
|
||||||
y_complete = self.data.get_guidelines_y()
|
y_complete = self.data.get_guidelines_y()
|
||||||
|
|
||||||
|
ind = 0
|
||||||
self.line_gl = []
|
self.line_gl = []
|
||||||
for x, y in zip(x_complete, y_complete):
|
for x, y in zip(x_complete, y_complete):
|
||||||
line = self.canvas.axes.plot(
|
line = self.canvas.axes.plot(
|
||||||
x, y,
|
x, y, color=self.colors[ind]
|
||||||
)
|
)
|
||||||
self.line_gl.append(line)
|
self.line_gl.append(line)
|
||||||
|
ind += 1
|
||||||
|
|
||||||
def draw_current(self):
|
def draw_current(self):
|
||||||
# Previous profile
|
# Previous profile
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,6 @@ class GeometryWindow(PamhyrWindow):
|
||||||
canvas=self._canvas_ac,
|
canvas=self._canvas_ac,
|
||||||
data=self._reach,
|
data=self._reach,
|
||||||
toolbar=self._toolbar_ac,
|
toolbar=self._toolbar_ac,
|
||||||
plot_xy=self._plot_xy
|
|
||||||
)
|
)
|
||||||
self._plot_ac.draw()
|
self._plot_ac.draw()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import matplotlib.colors as mplcolors
|
||||||
|
|
||||||
from View.Tools.Plot.APlot import APlot
|
from View.Tools.Plot.APlot import APlot
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
@ -31,6 +33,8 @@ class PamhyrPlot(APlot):
|
||||||
color_plot_current = "blue"
|
color_plot_current = "blue"
|
||||||
color_plot_next = "purple"
|
color_plot_next = "purple"
|
||||||
|
|
||||||
|
colors = list(mplcolors.TABLEAU_COLORS)
|
||||||
|
|
||||||
plot_default_kargs = {
|
plot_default_kargs = {
|
||||||
"lw" : 1.,
|
"lw" : 1.,
|
||||||
"markersize" : 3,
|
"markersize" : 3,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue