Regression Report matplotlib error - related to newest version

Issue #625 resolved
Fabian Thiel created an issue

Creation of Regression Performance Report causes matplotlib error on MacOSX, Ubuntu and Windows

Seems to be matplotlib version related, not OS related (as initially thought)

  • Working: matplotlib 3.1.3
  • Not Working: matplotlib 3.3.4
QGIS version: 3.16.3-Hannover
Qt version: 5.12.8
GDAL version: 3.0.4
GEOS version: 3.8.0-CAPI-1.13.1 
PROJ version: Rel. 6.3.1, February 10th, 2020
Processing algorithm
Algorithm 'Regression Performance' starting
Input parameters:
{ 'invertMask' : False, 'mask' : None, 'outReport' : './outReport.html', 'prediction' : '/mnt/c/Users/thielf54/Desktop/_temp/lenc/test1/TCD_cropped_scaled.tif', 'reference' : '/mnt/c/Users/thielf54/Desktop/_temp/lenc/test1/TCD_cropped_scaled.tif' }

{'invertMask': False, 'mask': None, 'outReport': './outReport.html', 'prediction': 'TCD_cropped_scaled_tif_ad7b8c2b_23de_4bb0_8e22_023a61ffd1dd', 'reference': 'TCD_cropped_scaled_tif_ad7b8c2b_23de_4bb0_8e22_023a61ffd1dd'}
Traceback (most recent call last):
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxgeoalgorithms/provider.py", line 152, in processAlgorithm
result = self.processAlgorithm_()
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxgeoalgorithms/algorithms.py", line 1524, in processAlgorithm_
performance.report().saveHTML(filename=filename, open=True)
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/core.py", line 6028, in report
report.append(ReportPlot(fig)) # , caption=fittedLineText))
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/report.py", line 176, in __init__
array = fig2rgb_array()
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/report.py", line 170, in fig2rgb_array
figure.canvas.draw()
File "/root/.local/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
self.figure.draw(self.renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw
mimage._draw_list_compositing_images(
File "/root/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
return func(*inner_args, **inner_kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2747, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/root/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 931, in draw
Collection.draw(self, renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 406, in draw
renderer.draw_path_collection(
File "/root/.local/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 172, in draw_path_collection
return self._renderer.draw_path_collection(
ValueError: Expected 2-dimensional array, got 1

Traceback (most recent call last):
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxgeoalgorithms/provider.py", line 152, in processAlgorithm
result = self.processAlgorithm_()
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxgeoalgorithms/algorithms.py", line 1524, in processAlgorithm_
performance.report().saveHTML(filename=filename, open=True)
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/core.py", line 6028, in report
report.append(ReportPlot(fig)) # , caption=fittedLineText))
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/report.py", line 176, in __init__
array = fig2rgb_array()
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/hubflow/report.py", line 170, in fig2rgb_array
figure.canvas.draw()
File "/root/.local/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
self.figure.draw(self.renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw
mimage._draw_list_compositing_images(
File "/root/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
return func(*inner_args, **inner_kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2747, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/root/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 931, in draw
Collection.draw(self, renderer)
File "/root/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 406, in draw
renderer.draw_path_collection(
File "/root/.local/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 172, in draw_path_collection
return self._renderer.draw_path_collection(
ValueError: Expected 2-dimensional array, got 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxgeoalgorithms/provider.py", line 166, in processAlgorithm
raise Exception('unexpected error')
Exception: unexpected error

Execution failed after 0.79 seconds

Loading resulting layers
Algorithm 'Regression Performance' finished

Comments (9)

  1. Benjamin Jakimow

    I don’t have much experience with matplotlib. @Andreas Janz can you provide a short snipped that we can use to test fig2rgb_array or figure.canvas.draw() from QGIS python?

  2. Fabian Thiel reporter

    The problem is, @Benjamin Jakimow 's Package Installer uses the local requirements file. Hence a change now will have no effect for the version in the plugion repo. Unless we say we want to include it in tomorrows (?) update?

  3. Benjamin Jakimow

    I’d prefer to make it running with the recent matplotlib release instead of enforcing older versions.

  4. Log in to comment