hi,
i am trying to separate the logic of matplotlib and wx gui elements. means i dont want to have plotting logic in wxpanel. so calculation which it based on can be done separetly.
in the sample app below, a panel is having 3 sizers…
one of the sizer is having the canvas of figure…
so far i can return the fig object at the from the calc. part, but cannot find a way to add to current panel.
i tried many combinations from stackovf but cant find the right answer. .
any suggestions?
It’s hard for me to tell what you want your code to do. It seems you are creating and even re-creating FigureCanvas() instances, but may not be fully drawing them. Your third_value() method seems to create an Axes3D and put into a new FigureCanvas (overwriting the value of self.canvas created in MyFrame1.__init__(), but not used. I would guess that you want to make a different figure / figurecanvas and Panel and show that somewhere else?
As da-dada mentioned, the wxmplot library might be useful. If not directly, then perhaps as a fair amount of working, testable code that gives examples of how to combine matplotlib with wx effectively.
In this case, I don’t think you need to define localz_method function in y_method method. To share data between y_method and z_method, your model would be:
class myfigure_1():
def _init__(self):
...
self.X = X
self.Y = Y
self.Z = Z
def y_method(myfig, abc):
ax = Axes3D(myfig)
ax.plot_wireframe(self.X, self.Y, self.Z)
def z_method(myfig):
ax = myfig.axes[0]
...
I think axes object is more appropriate than figure object as an argument of plot functions.
In my understanding, axes is a real plotting field of the artists, while figure is just a holder of one or more axes and provides some helper functions.
Well, the wxGlade examples are complete and runnable and are showing how to integrate wxPython and matplotlib, including some more advanced topics.
Your code is too far away from doing useful things as to expect someone else to fix it. You should start with looking at code that is actually working and then adapt things to your needs.