Open cslotboom opened 4 years ago
This is good.
In #77 I begin work on this. It's better to discuss some things here. The your biggest comment was reusing the plot_model_deformation(). I think this is ideal, but there are a few challenges.
The main problem is with the "_plot_on_click" function, which needs to know about DeflectedNodeCoordArray. I don't know how to pass this variable to the function because it is a matplotlib event.
def _plot_on_click(self, event):
timeSteps = self.timeSteps
Disp_nodeArray = self.Disp_nodeArray
# Find the Node ID
ind = event.ind[0]
fig, ax = plt.subplots()
line = ax.plot(timeSteps, self.scale*Disp_nodeArray[:,ind,0])
ax.set_xlabel('time (s)')
ax.set_ylabel('Displacement')
There are a few ways around this, i.e. global variables. However, generally using a class would work best.
It might be possible for us to call the existing plot function in our class, but that might require some shuffling around. We need to call fig.canvas.mpl_connect on the figure, before the plt.show(). Right now plt.show() is hard coded into the plot_model_defomration() function.
fig.canvas.mpl_connect('pick_event', self._plot_on_click)
plt.show()
I thought this matplotlib example was something we could potentially integrate into future functions:
We can potentially use click events to show data, some examples might be:
Just wanted to raise it for discussion.