Skip to content
Snippets Groups Projects

added labels to graphs axis

Merged SIMAILA DJALIM requested to merge graph_labels into main
2 files
+ 34
9
Compare changes
  • Side-by-side
  • Inline
Files
2
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)
Loading