CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
527 stars 180 forks source link

AttributeError: 'RendererAgg' object has no attribute 'M' #511

Closed ChemEng227 closed 1 month ago

ChemEng227 commented 6 months ago

Expected Behavior

Running d01 on TIGRE for Python in a nightly build of 12/11.

Actual Behavior

An Expection was thrown, the traceback as follows:

Exception in Tkinter callback Traceback (most recent call last): File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/tkinter/init.py", line 1948, in call return self.func(args) ^^^^^^^^^^^^^^^^ File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/tkinter/init.py", line 861, in callit func(args) File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 251, in idle_draw self.draw() File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/backends/backend_tkagg.py", line 10, in draw super().draw() File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 405, in draw self.figure.draw(self.renderer) File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/artist.py", line 74, in draw_wrapper result = draw(artist, renderer, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/figure.py", line 3082, in draw mimage._draw_list_compositing_images( File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 467, in draw super().draw(renderer) File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/axes/_base.py", line 3100, in draw mimage._draw_list_compositing_images( File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/home/cq/anaconda3/envs/TIGRE/lib/python3.11/site-packages/tigre/utilities/visualization/plot_geometry.py", line 18, in draw xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M) ^^^^^^^^^^ AttributeError: 'RendererAgg' object has no attribute 'M'

Code to reproduce the problem (If applicable)

d01.
Tried matplotlib versions of 3.8, 3.7 and 3.6. None worked.

Specifications

AnderBiguri commented 6 months ago

Hi @ChemEng227 , I have not changed anything in TIGRE plotting in months, so something else in your nightly must have changed. You say that its not matplotlib, but must be something else then.

It looks like it has to do with the graphic engine being used. Can you let me know which matplotlib renderer does your system use?

ChemEng227 commented 6 months ago

Hi @ChemEng227 , I have not changed anything in TIGRE plotting in months, so something else in your nightly must have changed. You say that its not matplotlib, but must be something else then.

It looks like it has to do with the graphic engine being used. Can you let me know which matplotlib renderer does your system use?

matplotlib.get_backend() returns 'QtAgg' in my environment.

AnderBiguri commented 6 months ago

Thanks! AFAIK QtAgg should support this, so I am not sure what is going on. I will try to investigate but its hard without being able to reproduce it. I would suggest not running d01 in your builds for now, in particular plot_geometry is not a critical function to use TIGRE.

amberhappy commented 5 months ago

same problem.

reginaoli commented 3 months ago

Hello! I had the same problem. But the error disappeared when I wrote in the beginning of the script these lines: import matplotlib matplotlib.use('QtAgg') However, the figure freezes and it does not appear. Anyone can help me overcome this problem? Thank you in advance!

AnderBiguri commented 3 months ago

@reginaoli can you tell me more about which machine are you running this on?

reginaoli commented 2 months ago

So, I changed the code editor (from spyder to vscode) and upgraded the versions of all the libraries and I can see the plots and graphics now. Thanks!!