From 0a63f5d710c0a6cfe98b52adbda1ea6fc6d6645d Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 15:36:43 +0200 Subject: [PATCH 1/3] Fix AttributeError: module 'plotly.graph_objs' has no attribute 'Area': it is go.Barplot in recent plotly versions --- python/plugins/processing/algs/qgis/PolarPlot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/plugins/processing/algs/qgis/PolarPlot.py b/python/plugins/processing/algs/qgis/PolarPlot.py index a2e2100488a2..33bb9db0353d 100644 --- a/python/plugins/processing/algs/qgis/PolarPlot.py +++ b/python/plugins/processing/algs/qgis/PolarPlot.py @@ -89,8 +89,9 @@ def processAlgorithm(self, parameters, context, feedback): values = vector.values(source, valuefieldname) - data = [go.Area(r=values[valuefieldname], - t=np.degrees(np.arange(0.0, 2 * np.pi, 2 * np.pi / len(values[valuefieldname]))))] + data = [go.Barpolar(r=values[valuefieldname], + theta=np.degrees(np.arange(0.0, 2 * np.pi, 2 * np.pi / len(values[valuefieldname]))))] + plt.offline.plot(data, filename=output, auto_open=False) return {self.OUTPUT: output} From 8851cc61cec0206498829f118dc81d8a1f49dd8c Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 15:41:22 +0200 Subject: [PATCH 2/3] value field must be numeric --- python/plugins/processing/algs/qgis/PolarPlot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/plugins/processing/algs/qgis/PolarPlot.py b/python/plugins/processing/algs/qgis/PolarPlot.py index 33bb9db0353d..2d89b08540c7 100644 --- a/python/plugins/processing/algs/qgis/PolarPlot.py +++ b/python/plugins/processing/algs/qgis/PolarPlot.py @@ -52,7 +52,9 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterField(self.NAME_FIELD, self.tr('Category name field'), parentLayerParameterName=self.INPUT)) # FIXME unused? self.addParameter(QgsProcessingParameterField(self.VALUE_FIELD, - self.tr('Value field'), parentLayerParameterName=self.INPUT)) + self.tr('Value field'), + parentLayerParameterName=self.INPUT, + type=QgsProcessingParameterField.DataType.Numeric)) self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Polar plot'), self.tr('HTML files (*.html)'))) From 08817e02473d9ad1f3c438880dcb5c20dc886e99 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Mon, 30 Sep 2024 09:09:15 +0200 Subject: [PATCH 3/3] Fix indentation --- python/plugins/processing/algs/qgis/PolarPlot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/plugins/processing/algs/qgis/PolarPlot.py b/python/plugins/processing/algs/qgis/PolarPlot.py index 2d89b08540c7..07fa5e5e55ee 100644 --- a/python/plugins/processing/algs/qgis/PolarPlot.py +++ b/python/plugins/processing/algs/qgis/PolarPlot.py @@ -92,7 +92,7 @@ def processAlgorithm(self, parameters, context, feedback): values = vector.values(source, valuefieldname) data = [go.Barpolar(r=values[valuefieldname], - theta=np.degrees(np.arange(0.0, 2 * np.pi, 2 * np.pi / len(values[valuefieldname]))))] + theta=np.degrees(np.arange(0.0, 2 * np.pi, 2 * np.pi / len(values[valuefieldname]))))] plt.offline.plot(data, filename=output, auto_open=False)