-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FigureCanvasTkAgg - "buffer is of wrong type" error during blit #9799
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
Comments
Can you update your matplotlib to 2.1? Those are working for me on osx--though the |
Unfortunately, still the same issue |
I have found something that might help,
and the image was correctly written to the png file. Hence the data are there but cannot be plot in Tk canvas?? |
Is that the full traceback you got? Can you get any debugging hooks in to sort out exactly what is in Lines 81 to 88 in 26382a7
When you are having these issues, how much free memory is there on the system? Where does |
Yes unfortunately that is the full traceback I have got. I believe (as seen from the code) that the bufferobj is argv[2] and from https://github.com/matplotlib/matplotlib/blob/v1.5.3/lib/matplotlib/backends/tkagg.py I can assume that the argument that is passed in position 2 is the memory position- From a windbg session I have found that there is an ACCESS VIOLATION crash in numpy's multiarray
StackTrace
I can assume that probably Another thing though is that, when I get this exception and call I have 32Gb of RAM and at the time that this error appears I have plenty of RAM available. The problem is if there is some Tkinter limitation on memory per application - which I don't know - that causes these issues, but surely a better explanation on the exception would clear things out. Do you believe it would be easy to send me a compiled version of Matplotlib which would explain the exception better? PopUpDialog is an internal class of our program which is basically a Tk popupwindow with a 2 Tk Frames. The top Tk Frame is used to place FiguraCanvasTkAgg inside. |
Can you check whether #9356 fixes this issue? |
Matplotlib 3.0.0 resolves this issue |
Bug report
Bug summary
I am trying to embed matplotlib in a Tk Canvas using FigureCanvasTkAgg. The Tk canvas itself is embedded in a Tk Frame, that can be resized. At certain dimensions of the Tk Frame the FigureCanvasTkAgg fails during the call to its draw function and throws the following exception:
I am using this functionality in a greater cae standalone program that uses Tk for its gui and the problem only happens when the cae files that we load on our program occupy around 2gb of RAM. When smaller files are loaded this issue does not appear. However if before loading the small files, we have loaded large files the issue keeps coming up even for the small ones.
I used the code from matplotlib site (https://matplotlib.org/1.5.3/examples/user_interfaces/embedding_in_tk.html) to demonstrate that the issue does not have to do with my code, since when the large models are loaded, this example also produces the same errors.
Now, after this error appears, if the user resizes the window and is lucky to find a correct dimension for the Tk window that contains the canvas, then the issue stops appearing and the FigureCanvasTkAgg draws itself successfully.
I understand that the exception is raised from this code https://github.com/matplotlib/matplotlib/blob/v1.5.3/lib/matplotlib/backends/tkagg.py (line 32)
and by searching a little bit I have found that the call to PyAggImagePhoto fails, probably in this code https://github.com/matplotlib/matplotlib/blob/v1.5.3/src/_tkagg.cpp (line 85).
If I am not mistaken, it tries to instantiate a numpy::array_view class passing it the figureCanvasTkAgg.renderer._renderer python object as a parameter, and somehow this throws the exception.
I have even tested with this code https://matplotlib.org/1.5.3/examples/user_interfaces/embedding_in_tk_canvas.html (it is using FigureCanvasAgg) and the issue still appears.
Code for reproduction
You can use the example from matplotlib site (https://matplotlib.org/1.5.3/examples/user_interfaces/embedding_in_tk.html)
Expected outcome
The canvas should be drawn and the error should not appear
Matplotlib version
Matplotlib has been installed through pip.
The text was updated successfully, but these errors were encountered: