New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matplotlib loosing axis labels and legend after update #242
Comments
Calling The issue is that the canvas needs redrawing. If you modify the function to include:
Then they are added to the plot, but not shown until the canvas is redrawn - try resizing it to prove that. To do it programatically, you'll need to force a redraw, after updating the axes: So, the full function would look like:
|
That's quite a mouthful! So you might want to put that bit of code in its own function:
You can then call that from both places. FYI - the initial label/legend only show as they're added before the GUI is drawn, I'll update the docs to make this more clear. |
PS. the matplotlib support is very rudimentary - there are various difficulties getting tkinter and matplotlib to play together nicely - I think I've overcome them... Do let me know how you get on, any issues you come across or features you'd like - I don't have too much experience with it myself, and haven't seen many people use it in appJar. |
This is the updated code I'm going to put in the example (I borrowed bits from yours):
|
Okay thanks for the quick workaround! But for a "beta widget" it is really cool to have such a powerful plotting function available in an easy UI lib such as appJar! |
I'll look into preserving the axes information - like I said, don't really know much about it. There is a fairly generic function for getting widgets, which will then give you access to the axes object: That will save you having to keep a reference to the axes... |
At the moment, I guess the If this isn't the desired result, then you can perform whichever actions you'd like directly on the axes - just make sure you call I'll keep digging into matplotlib on how to persist the labels and change the plot - let me know if you know how to do this already... |
I've looked into this a bit - there are LOTS of settings a user could configure on the axes. I can see a way to I actually think this might be a feature I don't want. I don't think appJar should be doing any of the work for matplotlib. I've set it up so tkinter & matplotlib play nicely together, and given a way to add a widget containing a plot, the rest should be down to the user. If the user is changing the plot, then the title/labels/legend may need to be changed as well. If not, then it's not a big job to set them again. I might provide a boolean flag (defaulting to False) on |
I've also noticed that the code for Plots seems to be repeated in appJar - that needs to be fixed. |
Also added in code to attempt to retain labels. Some landscape tidying up.
Now have a flag to 'retain' labels - but doesn't get the legend. |
Closing, see #267 |
After updating a plot xlabel, ylabel and legend is lost. Since updatePlot() does not return an axis object one cannot add the information again.
The following code triggers the bug:
The text was updated successfully, but these errors were encountered: