added labels to graphs axis

This commit is contained in:
Djalim Simaila 2023-04-28 09:41:56 +02:00
parent 39e6f494bd
commit 5897f874b5
2 changed files with 34 additions and 9 deletions

View File

@ -1,7 +1,7 @@
import vispy.plot as vp
import numpy as np
def render2D(values:list,title:str,show:bool=True):
def render2D(values:list,title:str,xlabel="",ylabel="",show:bool=True):
"""
Render a 2D plot using vispy
:param values: A list with the values
@ -9,13 +9,18 @@ def render2D(values:list,title:str,show:bool=True):
fig = vp.Fig(size=(600, 500), show=False)
plotwidget = fig[0, 0]
fig.title = title
plotwidget.plot(values,marker_size=0, width=2,title=title)
plotwidget.plot(values,
marker_size=0,
width=2,
title=title,
xlabel=xlabel,
ylabel=ylabel)
if show:
fig.show(run=True)
else:
return fig
def cross_section(x_values:list, y_values:list,title:str, show:bool=True ):
def cross_section(x_values:list, y_values:list,title:str,xlabel="",ylabel="",show:bool=True ):
"""
Render a 2D cross section using vispy
:param x: A list with the x values
@ -23,9 +28,15 @@ def cross_section(x_values:list, y_values:list,title:str, show:bool=True ):
"""
color = (0.3, 0.5, 0.8,.8)
fig = vp.Fig(show=False)
line = fig[0:4, 0:4].plot(np.column_stack((x_values,y_values)), symbol='disc', width=0,
face_color=color, edge_color=None,
marker_size=8,title=title)
line = fig[0:4, 0:4].plot(np.column_stack((x_values,y_values)),
symbol='disc',
width=0,
face_color=color,
edge_color=None,
marker_size=8,
title=title,
xlabel=xlabel,
ylabel=ylabel)
line.set_gl_state(depth_test=False)
if show:
fig.show(run=True)

View File

@ -249,11 +249,25 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
if graph_type == "Mesh3D":
current_slot.addWidget(render3D(obj,False).native)
if graph_type == "Coupe XZ":
current_slot.addWidget(cross_section(obj.get_x(),obj.get_z(),"Coupe XZ",False).native)
current_slot.addWidget(cross_section(obj.get_x(),
obj.get_z(),
"Coupe XZ",
"X (en mm)",
"Z (en mm)",
False).native)
if graph_type == "Coupe YZ":
current_slot.addWidget(cross_section(obj.get_y(),obj.get_z(),"Coupe YZ",False).native)
current_slot.addWidget(cross_section(obj.get_y(),
obj.get_z(),
"Coupe YZ",
"Y (en mm)",
"Z (en mm)",
False).native)
if graph_type == "Evolution du rayon moyen":
current_slot.addWidget(render2D(list(zip(discrete_data['Z moy (en mm)'],discrete_data['Rayon moyen (en mm)'])),"Evolution du rayon moyen",False).native)
current_slot.addWidget(render2D(list(zip(discrete_data['Z moy (en mm)'],discrete_data['Rayon moyen (en mm)'])),
"Evolution du rayon moyen en fonction de Z",
"Z (en mm)",
"Rayon moyen (en mm)\n",
False).native)
def clear_graphs(self):
"""