From aa6b869574c2cb12709daee489f602bd131bb0d3 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 14:35:25 +0200 Subject: [PATCH 01/14] Add title, xaxis_title, yaxis_title to BarPlot --- .../plugins/processing/algs/qgis/BarPlot.py | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index ff7dc1cca252..92af506bb320 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -25,7 +25,8 @@ QgsProcessingParameterFeatureSource, QgsProcessingParameterField, QgsProcessingException, - QgsProcessingParameterFileDestination) + QgsProcessingParameterFileDestination, + QgsProcessingParameterString,) from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm from processing.tools import vector @@ -37,6 +38,9 @@ class BarPlot(QgisAlgorithm): OUTPUT = 'OUTPUT' NAME_FIELD = 'NAME_FIELD' VALUE_FIELD = 'VALUE_FIELD' + TITLE = 'TITLE' + XAXIS_TITLE = "XAXIS_TITLE" + YAXIS_TITLE = "YAXIS_TITLE" def group(self): return self.tr('Plots') @@ -59,6 +63,21 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Bar plot'), self.tr('HTML files (*.html)'))) + self.addParameter(QgsProcessingParameterString( + self.TITLE, + self.tr('Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.XAXIS_TITLE, + self.tr('Xaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.YAXIS_TITLE, + self.tr('Yaxis Title'), + optional=True)) + def name(self): return 'barplot' @@ -83,6 +102,14 @@ def processAlgorithm(self, parameters, context, feedback): namefieldname = self.parameterAsString(parameters, self.NAME_FIELD, context) valuefieldname = self.parameterAsString(parameters, self.VALUE_FIELD, context) + title = self.parameterAsString(parameters, self.TITLE, context) + xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) + yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + + if title.strip() == "": title = None + if xaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": xaxis_title = None + output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) values = vector.values(source, valuefieldname) @@ -91,6 +118,13 @@ def processAlgorithm(self, parameters, context, feedback): data = [go.Bar(x=x_var, y=values[valuefieldname])] - plt.offline.plot(data, filename=output, auto_open=False) + + fig = go.Figure( + data=data, + layout_title_text=title, + layout_xaxis_title=xaxis_title, + layout_yaxis_title=yaxis_title) + + fig.write_html(output) return {self.OUTPUT: output} From 986e0dd4deb1b0a31b7afc5a6771a357f59f271a Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 14:48:30 +0200 Subject: [PATCH 02/14] Add title, xaxis_title, yaxis_title to BoxPlot --- .../plugins/processing/algs/qgis/BoxPlot.py | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 9fbd5559d375..18caa8a1b2f9 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -26,7 +26,8 @@ QgsProcessingParameterField, QgsProcessingParameterEnum, QgsProcessingParameterFileDestination, - QgsFeatureRequest) + QgsFeatureRequest, + QgsProcessingParameterString) from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm from processing.tools import vector @@ -39,6 +40,9 @@ class BoxPlot(QgisAlgorithm): NAME_FIELD = 'NAME_FIELD' VALUE_FIELD = 'VALUE_FIELD' MSD = 'MSD' + TITLE = 'TITLE' + XAXIS_TITLE = "XAXIS_TITLE" + YAXIS_TITLE = "YAXIS_TITLE" def group(self): return self.tr('Plots') @@ -69,6 +73,21 @@ def initAlgorithm(self, config=None): self.tr('Additional Statistic Lines'), options=msd, defaultValue=0)) + self.addParameter(QgsProcessingParameterString( + self.TITLE, + self.tr('Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.XAXIS_TITLE, + self.tr('Xaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.YAXIS_TITLE, + self.tr('Yaxis Title'), + optional=True)) + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Box plot'), self.tr('HTML files (*.html)'))) def name(self): @@ -95,6 +114,14 @@ def processAlgorithm(self, parameters, context, feedback): namefieldname = self.parameterAsString(parameters, self.NAME_FIELD, context) valuefieldname = self.parameterAsString(parameters, self.VALUE_FIELD, context) + title = self.parameterAsString(parameters, self.TITLE, context) + xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) + yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + + if title.strip() == "": title = None + if xaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": xaxis_title = None + output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) values = vector.values(source, valuefieldname) @@ -115,6 +142,12 @@ def processAlgorithm(self, parameters, context, feedback): y=values[valuefieldname], boxmean=msd)] - plt.offline.plot(data, filename=output, auto_open=False) + fig = go.Figure( + data=data, + layout_title_text=title, + layout_xaxis_title=xaxis_title, + layout_yaxis_title=yaxis_title) + + fig.write_html(output) return {self.OUTPUT: output} From 3937c42a6b04ad6824cae99b431d35a013c0fe1d Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 15:10:39 +0200 Subject: [PATCH 03/14] Parameter value must be numeric --- python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py b/python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py index 2b665370f758..acf235e7d5a5 100644 --- a/python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py +++ b/python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py @@ -54,7 +54,9 @@ def initAlgorithm(self, config=None): self.tr('Category name field'), parentLayerParameterName=self.INPUT, type=QgsProcessingParameterField.DataType.Any)) 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('Plot'), self.tr('HTML files (*.html)'))) From 917dbbd2c7086a8760cf5e0dc8905bd8a296fd9c Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 16:13:03 +0200 Subject: [PATCH 04/14] Add title and axis titles to Vector layer Scatterplot3D --- .../algs/qgis/VectorLayerScatterplot3D.py | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 52eb032b41b2..7aaad86905cd 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -23,7 +23,9 @@ from qgis.core import (QgsProcessingParameterFeatureSource, QgsProcessingParameterField, QgsProcessingParameterFileDestination, - QgsProcessingException) + QgsProcessingException, + QgsProcessingParameterString) + from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm from processing.tools import vector @@ -37,6 +39,10 @@ class VectorLayerScatterplot3D(QgisAlgorithm): XFIELD = 'XFIELD' YFIELD = 'YFIELD' ZFIELD = 'ZFIELD' + TITLE = 'TITLE' + XAXIS_TITLE = "XAXIS_TITLE" + YAXIS_TITLE = "YAXIS_TITLE" + ZAXIS_TITLE = "ZAXIS_TITLE" def group(self): return self.tr('Plots') @@ -63,6 +69,26 @@ def initAlgorithm(self, config=None): parentLayerParameterName=self.INPUT, type=QgsProcessingParameterField.DataType.Numeric)) + self.addParameter(QgsProcessingParameterString( + self.TITLE, + self.tr('Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.XAXIS_TITLE, + self.tr('Xaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.YAXIS_TITLE, + self.tr('Yaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.ZAXIS_TITLE, + self.tr('Zaxis Title'), + optional=True)) + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Histogram'), self.tr('HTML files (*.html)'))) def name(self): @@ -90,6 +116,16 @@ def processAlgorithm(self, parameters, context, feedback): yfieldname = self.parameterAsString(parameters, self.YFIELD, context) zfieldname = self.parameterAsString(parameters, self.ZFIELD, context) + title = self.parameterAsString(parameters, self.TITLE, context) + xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) + yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + zaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + + if title.strip() == "": title = None + if xaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": xaxis_title = None + if zaxis_title.strip() == "": xaxis_title = None + output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) values = vector.values(source, xfieldname, yfieldname, zfieldname) @@ -100,6 +136,14 @@ def processAlgorithm(self, parameters, context, feedback): z=values[zfieldname], mode='markers')] - plt.offline.plot(data, filename=output, auto_open=False) + + fig = go.Figure( + data=data, + layout_title_text=title, + layout_scene_xaxis_title=xaxis_title, + layout_scene_yaxis_title=yaxis_title, + layout_scene_zaxis_title=zaxis_title) + + fig.write_html(output) return {self.OUTPUT: output} From 3ff6b896026765b7f82d44ed84329e45552e323d Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 27 Sep 2024 16:33:07 +0200 Subject: [PATCH 05/14] Add title, axis titles and option for log axis to Vector layer Scatterplot --- .../algs/qgis/VectorLayerScatterplot.py | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py index 33db3604c8e1..ce86818f7ce4 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py @@ -23,7 +23,10 @@ from qgis.core import (QgsProcessingException, QgsProcessingParameterFeatureSource, QgsProcessingParameterField, - QgsProcessingParameterFileDestination) + QgsProcessingParameterFileDestination, + QgsProcessingParameterString, + QgsProcessingParameterBoolean) + from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm from processing.tools import vector @@ -35,6 +38,11 @@ class VectorLayerScatterplot(QgisAlgorithm): OUTPUT = 'OUTPUT' XFIELD = 'XFIELD' YFIELD = 'YFIELD' + TITLE = 'TITLE' + XAXIS_TITLE = "XAXIS_TITLE" + YAXIS_TITLE = "YAXIS_TITLE" + XAXIS_LOG = "XAXIS_LOG" + YAXIS_LOG = "YAXIS_LOG" def group(self): return self.tr('Plots') @@ -57,6 +65,33 @@ def initAlgorithm(self, config=None): parentLayerParameterName=self.INPUT, type=QgsProcessingParameterField.DataType.Numeric)) + self.addParameter(QgsProcessingParameterString( + self.TITLE, + self.tr('Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.XAXIS_TITLE, + self.tr('Xaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterString( + self.YAXIS_TITLE, + self.tr('Yaxis Title'), + optional=True)) + + self.addParameter(QgsProcessingParameterBoolean( + self.XAXIS_LOG, + self.tr('Xaxis logarithmic'), + defaultValue=False, + optional=True)) + + self.addParameter(QgsProcessingParameterBoolean( + self.YAXIS_LOG, + self.tr('Yaxis logarithmic'), + defaultValue=False, + optional=True)) + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Scatterplot'), self.tr('HTML files (*.html)'))) def name(self): @@ -83,12 +118,34 @@ def processAlgorithm(self, parameters, context, feedback): xfieldname = self.parameterAsString(parameters, self.XFIELD, context) yfieldname = self.parameterAsString(parameters, self.YFIELD, context) + title = self.parameterAsString(parameters, self.TITLE, context) + xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) + yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + xaxis_log = self.parameterAsBool(parameters, self.XAXIS_LOG, context) + yaxis_log = self.parameterAsBool(parameters, self.YAXIS_LOG, context) + + if title.strip() == "": title = None + if xaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": yaxis_title = None + output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) values = vector.values(source, xfieldname, yfieldname) data = [go.Scatter(x=values[xfieldname], y=values[yfieldname], mode='markers')] - plt.offline.plot(data, filename=output, auto_open=False) + fig = go.Figure( + data=data, + layout_title_text=title, + layout_xaxis_title=xaxis_title, + layout_yaxis_title=yaxis_title) + + if xaxis_log: + fig.update_xaxes(type="log") + + if yaxis_log: + fig.update_yaxes(type="log") + + fig.write_html(output) return {self.OUTPUT: output} From d0d70ef18d83c58c6ec72fcbcd1cab48de63dd4d Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Sat, 28 Sep 2024 12:59:36 +0200 Subject: [PATCH 06/14] Was setting the wrong axis titles to None --- python/plugins/processing/algs/qgis/BarPlot.py | 2 +- python/plugins/processing/algs/qgis/BoxPlot.py | 2 +- .../processing/algs/qgis/VectorLayerScatterplot3D.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index 92af506bb320..a99ac01056d7 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -108,7 +108,7 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": yaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 18caa8a1b2f9..0f76909c6f4d 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -120,7 +120,7 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": yaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 7aaad86905cd..3f2ea68b14e4 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -119,12 +119,12 @@ def processAlgorithm(self, parameters, context, feedback): title = self.parameterAsString(parameters, self.TITLE, context) xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) - zaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) + zaxis_title = self.parameterAsString(parameters, self.ZAXIS_TITLE, context) if title.strip() == "": title = None if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": xaxis_title = None - if zaxis_title.strip() == "": xaxis_title = None + if yaxis_title.strip() == "": yaxis_title = None + if zaxis_title.strip() == "": zaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) From 776aa3bbf2c453a1e75a190d2ee8fecb4e3caee3 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Sat, 28 Sep 2024 13:35:52 +0200 Subject: [PATCH 07/14] Axis titles default to the names of the field instead of not showing axis titles --- python/plugins/processing/algs/qgis/BarPlot.py | 9 ++++++--- python/plugins/processing/algs/qgis/BoxPlot.py | 9 ++++++--- .../processing/algs/qgis/VectorLayerScatterplot.py | 9 ++++++--- .../processing/algs/qgis/VectorLayerScatterplot3D.py | 12 ++++++++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index a99ac01056d7..2cf71c164bb1 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -106,9 +106,12 @@ def processAlgorithm(self, parameters, context, feedback): xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) - if title.strip() == "": title = None - if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": yaxis_title = None + if title.strip() == "": + title = None + if xaxis_title.strip() == "": + xaxis_title = namefieldname + if yaxis_title.strip() == "": + yaxis_title = valuefieldname output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 0f76909c6f4d..45f3127cde27 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -118,9 +118,12 @@ def processAlgorithm(self, parameters, context, feedback): xaxis_title = self.parameterAsString(parameters, self.XAXIS_TITLE, context) yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) - if title.strip() == "": title = None - if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": yaxis_title = None + if title.strip() == "": + title = None + if xaxis_title.strip() == "": + xaxis_title = namefieldname + if yaxis_title.strip() == "": + yaxis_title = valuefieldname output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py index ce86818f7ce4..7287569d5b0e 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py @@ -124,9 +124,12 @@ def processAlgorithm(self, parameters, context, feedback): xaxis_log = self.parameterAsBool(parameters, self.XAXIS_LOG, context) yaxis_log = self.parameterAsBool(parameters, self.YAXIS_LOG, context) - if title.strip() == "": title = None - if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": yaxis_title = None + if title.strip() == "": + title = None + if xaxis_title.strip() == "": + xaxis_title = xfieldname + if yaxis_title.strip() == "": + yaxis_title = yfieldname output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 3f2ea68b14e4..9ba05ad6a029 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -121,10 +121,14 @@ def processAlgorithm(self, parameters, context, feedback): yaxis_title = self.parameterAsString(parameters, self.YAXIS_TITLE, context) zaxis_title = self.parameterAsString(parameters, self.ZAXIS_TITLE, context) - if title.strip() == "": title = None - if xaxis_title.strip() == "": xaxis_title = None - if yaxis_title.strip() == "": yaxis_title = None - if zaxis_title.strip() == "": zaxis_title = None + if title.strip() == "": + title = None + if xaxis_title.strip() == "": + xaxis_title = xfieldname + if yaxis_title.strip() == "": + yaxis_title = yfieldname + if zaxis_title.strip() == "": + zaxis_title = zfieldname output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) From 73259172a4171fe0f08ce36d1e0565586cc03c49 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Mon, 30 Sep 2024 12:20:42 +0200 Subject: [PATCH 08/14] Remove blank line --- python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 9ba05ad6a029..0228dfcb82b9 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -140,7 +140,6 @@ def processAlgorithm(self, parameters, context, feedback): z=values[zfieldname], mode='markers')] - fig = go.Figure( data=data, layout_title_text=title, From d7f459aa34c0ba99dbdcc0778d18b572534ed7f6 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Tue, 1 Oct 2024 17:45:47 +0200 Subject: [PATCH 09/14] Add @florianneukirchen to CONTRIBUTORS --- doc/CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CONTRIBUTORS b/doc/CONTRIBUTORS index 44a1d4ae70b5..ea7bada48870 100644 --- a/doc/CONTRIBUTORS +++ b/doc/CONTRIBUTORS @@ -39,6 +39,7 @@ Even Rouault Fernando Pacheco Florian El Ahdab Florian Hof +Florian Neukirchen Frank Warmerdam Germán Carrillo Giovanni Manghi From d072ef6a3b5c80f754601bdf2fdf74d7e4c04641 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Thu, 7 Nov 2024 11:17:03 +0100 Subject: [PATCH 10/14] Allow to show no axis titles by entering a single space --- python/plugins/processing/algs/qgis/BarPlot.py | 8 ++++++-- python/plugins/processing/algs/qgis/BoxPlot.py | 6 +++++- .../processing/algs/qgis/VectorLayerScatterplot.py | 8 ++++++-- .../processing/algs/qgis/VectorLayerScatterplot3D.py | 6 +++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index 2cf71c164bb1..66dc0b4c8a0f 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -108,10 +108,14 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None - if xaxis_title.strip() == "": + if xaxis_title == "": xaxis_title = namefieldname - if yaxis_title.strip() == "": + elif xaxis_title == " ": + xaxis_title = None + if yaxis_title == "": yaxis_title = valuefieldname + elif yaxis_title == " ": + yaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 45f3127cde27..2c169e357711 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -120,10 +120,14 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None - if xaxis_title.strip() == "": + if xaxis_title == "": xaxis_title = namefieldname + elif xaxis_title == " ": + xaxis_title = None if yaxis_title.strip() == "": yaxis_title = valuefieldname + elif yaxis_title == " ": + yaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py index 7287569d5b0e..ee5171ca52d5 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py @@ -126,10 +126,14 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None - if xaxis_title.strip() == "": + if xaxis_title == "": xaxis_title = xfieldname - if yaxis_title.strip() == "": + elif xaxis_title == " ": + xaxis_title = None + if yaxis_title == "": yaxis_title = yfieldname + elif yaxis_title == " ": + yaxis_title = None output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 0228dfcb82b9..72495a61e85c 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -123,11 +123,11 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None - if xaxis_title.strip() == "": + if xaxis_title == "": xaxis_title = xfieldname - if yaxis_title.strip() == "": + if yaxis_title == "": yaxis_title = yfieldname - if zaxis_title.strip() == "": + if zaxis_title == "": zaxis_title = zfieldname output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) From 1b03d349aa73e3fda2ffa5adc1e1e5be0401697c Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Wed, 13 Nov 2024 20:40:26 +0100 Subject: [PATCH 11/14] Change strings as suggested in code review --- python/plugins/processing/algs/qgis/BarPlot.py | 4 ++-- python/plugins/processing/algs/qgis/BoxPlot.py | 4 ++-- .../processing/algs/qgis/VectorLayerScatterplot.py | 8 ++++---- .../processing/algs/qgis/VectorLayerScatterplot3D.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index 66dc0b4c8a0f..67f0f816e78a 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -70,12 +70,12 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('Xaxis Title'), + self.tr('X-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Yaxis Title'), + self.tr('Y-axis Title'), optional=True)) def name(self): diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 2c169e357711..8e76ddef26e3 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -80,12 +80,12 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('Xaxis Title'), + self.tr('X-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Yaxis Title'), + self.tr('Y-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Box plot'), self.tr('HTML files (*.html)'))) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py index ee5171ca52d5..5c99dffa8e82 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py @@ -72,23 +72,23 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('Xaxis Title'), + self.tr('X-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Yaxis Title'), + self.tr('Y-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterBoolean( self.XAXIS_LOG, - self.tr('Xaxis logarithmic'), + self.tr('Use logarithmic scale for x-axis'), defaultValue=False, optional=True)) self.addParameter(QgsProcessingParameterBoolean( self.YAXIS_LOG, - self.tr('Yaxis logarithmic'), + self.tr('Use logarithmic scale for y-axis'), defaultValue=False, optional=True)) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index 72495a61e85c..a0357e499999 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -76,20 +76,20 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('Xaxis Title'), + self.tr('X-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Yaxis Title'), + self.tr('Y-axis Title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.ZAXIS_TITLE, - self.tr('Zaxis Title'), + self.tr('Z-axis Title'), optional=True)) - self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Histogram'), self.tr('HTML files (*.html)'))) + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Scatterplot 3D'), self.tr('HTML files (*.html)'))) def name(self): return 'scatter3dplot' From 57b04bf01192e35ae7906824a69a0ab0dc2c9833 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Wed, 13 Nov 2024 21:14:07 +0100 Subject: [PATCH 12/14] Change strings as suggested in code review part 2 --- python/plugins/processing/algs/qgis/BarPlot.py | 4 ++-- python/plugins/processing/algs/qgis/BoxPlot.py | 4 ++-- .../plugins/processing/algs/qgis/VectorLayerScatterplot.py | 4 ++-- .../processing/algs/qgis/VectorLayerScatterplot3D.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index 67f0f816e78a..f17162870da9 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -70,12 +70,12 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('X-axis Title'), + self.tr('X-axis title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Y-axis Title'), + self.tr('Y-axis title'), optional=True)) def name(self): diff --git a/python/plugins/processing/algs/qgis/BoxPlot.py b/python/plugins/processing/algs/qgis/BoxPlot.py index 8e76ddef26e3..55d2d5ba7b7e 100644 --- a/python/plugins/processing/algs/qgis/BoxPlot.py +++ b/python/plugins/processing/algs/qgis/BoxPlot.py @@ -80,12 +80,12 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('X-axis Title'), + self.tr('X-axis title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Y-axis Title'), + self.tr('Y-axis title'), optional=True)) self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Box plot'), self.tr('HTML files (*.html)'))) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py index 5c99dffa8e82..b53fe434344f 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot.py @@ -72,12 +72,12 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('X-axis Title'), + self.tr('X-axis title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Y-axis Title'), + self.tr('Y-axis title'), optional=True)) self.addParameter(QgsProcessingParameterBoolean( diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index a0357e499999..be7a31ee64ae 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -76,17 +76,17 @@ def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterString( self.XAXIS_TITLE, - self.tr('X-axis Title'), + self.tr('X-axis title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.YAXIS_TITLE, - self.tr('Y-axis Title'), + self.tr('Y-axis title'), optional=True)) self.addParameter(QgsProcessingParameterString( self.ZAXIS_TITLE, - self.tr('Z-axis Title'), + self.tr('Z-axis title'), optional=True)) self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Scatterplot 3D'), self.tr('HTML files (*.html)'))) From 57763c9d7889f871a8394af9678afa9be71cf933 Mon Sep 17 00:00:00 2001 From: Florian Neukirchen Date: Fri, 15 Nov 2024 12:32:10 +0100 Subject: [PATCH 13/14] Add comment as suggested in code review --- python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index be7a31ee64ae..a1bbc9ef4ad3 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -123,6 +123,8 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None + # Passing None for axis titles to Plotly does not work in this case: Unlike in 2D charts, Plotly would use x, y, z as axis titles. + # If our users enter space, we still get invisible axes titles, resulting in the same behavoir as for the other algs. if xaxis_title == "": xaxis_title = xfieldname if yaxis_title == "": From 8a75d241b31d8bd4d1dcbeae719e79bb579a9aa3 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 28 Nov 2024 14:38:32 +1000 Subject: [PATCH 14/14] Update python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py --- python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py index a1bbc9ef4ad3..2039a4657431 100644 --- a/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py +++ b/python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py @@ -124,7 +124,7 @@ def processAlgorithm(self, parameters, context, feedback): if title.strip() == "": title = None # Passing None for axis titles to Plotly does not work in this case: Unlike in 2D charts, Plotly would use x, y, z as axis titles. - # If our users enter space, we still get invisible axes titles, resulting in the same behavoir as for the other algs. + # If our users enter space, we still get invisible axes titles, resulting in the same behavior as for the other algs. if xaxis_title == "": xaxis_title = xfieldname if yaxis_title == "":