AnalyseMorphologique/utils/graph2D/visplot_render.py
2023-04-26 15:45:34 +02:00

33 lines
1006 B
Python

import vispy.plot as vp
import numpy as np
def render2D(values:list,title:str,show:bool=True):
"""
Render a 2D plot using vispy
:param values: A list with the values
"""
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)
if show:
fig.show(run=True)
else:
return fig
def cross_section(x_values:list, y_values:list,title:str, show:bool=True ):
"""
Render a 2D cross section using vispy
:param x: A list with the x values
:param y: A list with the y values
"""
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.set_gl_state(depth_test=False)
if show:
fig.show(run=True)
else:
return fig