From 0cac67734565485c90b7aa6cb0abf408ddc76d72 Mon Sep 17 00:00:00 2001 From: Sophie Aubier Date: Thu, 13 Mar 2025 18:18:34 +0100 Subject: [PATCH 1/4] add legend style option : size, front, color --- DataPlotly/core/plot_settings.py | 9 +++++++++ DataPlotly/core/plot_types/plot_type.py | 9 ++++++++- DataPlotly/gui/plot_settings_widget.py | 13 +++++++++++++ DataPlotly/ui/dataplotly_dockwidget_base.ui | 17 +++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/DataPlotly/core/plot_settings.py b/DataPlotly/core/plot_settings.py index b78e643d..54ae584a 100644 --- a/DataPlotly/core/plot_settings.py +++ b/DataPlotly/core/plot_settings.py @@ -51,6 +51,9 @@ class PlotSettings: # pylint: disable=too-many-instance-attributes PROPERTY_FONT_YTICKS_SIZE = 27 PROPERTY_FONT_YTICKS_FAMILY = 28 PROPERTY_FONT_YTICKS_COLOR = 29 + PROPERTY_FONT_LEGEND_SIZE = 27 + PROPERTY_FONT_LEGEND_FAMILY = 28 + PROPERTY_FONT_LEGEND_COLOR = 29 DYNAMIC_PROPERTIES = { PROPERTY_FILTER: QgsPropertyDefinition('filter', 'Feature filter', QgsPropertyDefinition.Boolean), @@ -77,6 +80,9 @@ class PlotSettings: # pylint: disable=too-many-instance-attributes PROPERTY_FONT_YTICKS_SIZE: QgsPropertyDefinition('font_yticks_size', 'Font yticks size', QgsPropertyDefinition.String), PROPERTY_FONT_YTICKS_FAMILY: QgsPropertyDefinition('font_yticks_family', 'Font yticks family', QgsPropertyDefinition.String), PROPERTY_FONT_YTICKS_COLOR: QgsPropertyDefinition('font_yticks_color', 'Font yticks color', QgsPropertyDefinition.ColorWithAlpha), + PROPERTY_FONT_LEGEND_SIZE: QgsPropertyDefinition('font_legend_size', 'Font yticks size', QgsPropertyDefinition.String), + PROPERTY_FONT_LEGEND_FAMILY: QgsPropertyDefinition('font_legend_family', 'Font yticks family', QgsPropertyDefinition.String), + PROPERTY_FONT_LEGEND_COLOR: QgsPropertyDefinition('font_legend_color', 'Font yticks color', QgsPropertyDefinition.ColorWithAlpha), PROPERTY_X_TITLE: QgsPropertyDefinition('x_title', 'X title', QgsPropertyDefinition.String), PROPERTY_Y_TITLE: QgsPropertyDefinition('y_title', 'Y title', QgsPropertyDefinition.String), PROPERTY_Z_TITLE: QgsPropertyDefinition('z_title', 'Z title', QgsPropertyDefinition.String), @@ -169,6 +175,9 @@ def __init__(self, plot_type: str = 'scatter', properties: dict = None, layout: 'font_yticks_size': 10, 'font_yticks_family': "Arial", 'font_yticks_color': "#000000", + 'font_legend_size': 10, + 'font_legend_family': "Arial", + 'font_legend_color': "#000000", 'xaxis': None, 'bar_mode': None, 'x_type': None, diff --git a/DataPlotly/core/plot_types/plot_type.py b/DataPlotly/core/plot_types/plot_type.py index 8a21bd6e..5fcc7fee 100644 --- a/DataPlotly/core/plot_types/plot_type.py +++ b/DataPlotly/core/plot_types/plot_type.py @@ -106,7 +106,14 @@ def create_layout(settings): layout = graph_objs.Layout( showlegend=settings.layout['legend'], - legend={'orientation': settings.layout['legend_orientation']}, + legend={'orientation': settings.layout['legend_orientation'], + 'font': { + 'size': settings.layout.get('font_legend_size', 10), + 'color': settings.layout.get('font_legend_color', "#000"), + 'family': settings.layout.get('font_legend_family', "Arial"), + } + }, + title=title, xaxis={ 'title': { diff --git a/DataPlotly/gui/plot_settings_widget.py b/DataPlotly/gui/plot_settings_widget.py index be4b5e78..0de18f95 100644 --- a/DataPlotly/gui/plot_settings_widget.py +++ b/DataPlotly/gui/plot_settings_widget.py @@ -933,14 +933,17 @@ def refreshWidgets(self): # pylint: disable=too-many-statements,too-many-branch self.font_xticks_label: ['all'], self.font_ylabel_label: ['all'], self.font_yticks_label: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], + self.font_legend_label: ['all'], self.font_title_style: ['all'], self.font_xlabel_style: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], self.font_xticks_style: ['all'], self.font_ylabel_style: ['all'], self.font_yticks_style: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], + self.font_legend_style: ['all'], self.font_title_color: ['all'], self.font_xlabel_color: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], self.font_xticks_color: ['all'], + self.font_legend_color: ['all'], self.font_ylabel_color: ['all'], self.font_yticks_color: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], self.x_axis_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'ternary', 'violin'], @@ -1197,6 +1200,11 @@ def get_settings(self) -> PlotSettings: # pylint: disable=R0915 self.font_yticks_style.currentFont().pointSize()), 'font_yticks_family': self.font_yticks_style.currentFont().family(), 'font_yticks_color': self.font_yticks_color.color().name(), + 'font_legend_size': max( + self.font_legend_style.currentFont().pixelSize(), + self.font_legend_style.currentFont().pointSize()), + 'font_legend_family': self.font_legend_style.currentFont().family(), + 'font_legend_color': self.font_legend_color.color().name(), 'x_title': self.x_axis_title.text(), 'y_title': self.y_axis_title.text(), 'z_title': self.z_axis_title.text(), @@ -1315,6 +1323,11 @@ def set_settings(self, settings: PlotSettings): # pylint: disable=too-many-stat settings.layout.get('font_yticks_size', 10))) self.font_yticks_color.setColor( QColor(settings.layout.get('font_yticks_color', "#000000"))) + self.font_legend_style.setCurrentFont( + QFont(settings.layout.get('font_legend_style', "Arial"), + settings.layout.get('font_legend_size', 10))) + self.font_legend_color.setColor( + QColor(settings.layout.get('font_legend_color', "#000000"))) self.font_ylabel_style.setCurrentFont( QFont(settings.layout.get('font_ylabel_family', "Arial"), settings.layout.get('font_ylabel_size', 10))) diff --git a/DataPlotly/ui/dataplotly_dockwidget_base.ui b/DataPlotly/ui/dataplotly_dockwidget_base.ui index 7b763325..585101ee 100644 --- a/DataPlotly/ui/dataplotly_dockwidget_base.ui +++ b/DataPlotly/ui/dataplotly_dockwidget_base.ui @@ -1319,6 +1319,13 @@ QListWidget::item::selected { + + + + Legend font + + + @@ -1350,6 +1357,13 @@ QListWidget::item::selected { + + + + QgsFontButton::ModeQFont + + + @@ -1367,6 +1381,9 @@ QListWidget::item::selected { + + + From 269cfce5e5d0e126eb9ee6d395dbb67e588548d6 Mon Sep 17 00:00:00 2001 From: Sophie Aubier Date: Wed, 24 Sep 2025 09:30:47 +0200 Subject: [PATCH 2/4] Review : continue the numeration for PROPERTY_FONT_LEGEND --- DataPlotly/core/plot_settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DataPlotly/core/plot_settings.py b/DataPlotly/core/plot_settings.py index 54ae584a..9e7ec930 100644 --- a/DataPlotly/core/plot_settings.py +++ b/DataPlotly/core/plot_settings.py @@ -51,9 +51,9 @@ class PlotSettings: # pylint: disable=too-many-instance-attributes PROPERTY_FONT_YTICKS_SIZE = 27 PROPERTY_FONT_YTICKS_FAMILY = 28 PROPERTY_FONT_YTICKS_COLOR = 29 - PROPERTY_FONT_LEGEND_SIZE = 27 - PROPERTY_FONT_LEGEND_FAMILY = 28 - PROPERTY_FONT_LEGEND_COLOR = 29 + PROPERTY_FONT_LEGEND_SIZE = 30 + PROPERTY_FONT_LEGEND_FAMILY = 31 + PROPERTY_FONT_LEGEND_COLOR = 32 DYNAMIC_PROPERTIES = { PROPERTY_FILTER: QgsPropertyDefinition('filter', 'Feature filter', QgsPropertyDefinition.Boolean), From d41ecf578ab3181391dfb564e3a742ebc93058aa Mon Sep 17 00:00:00 2001 From: Sophie Aubier Date: Wed, 24 Sep 2025 09:37:08 +0200 Subject: [PATCH 3/4] Review: add font_legend_color & font_legend_style to the default colors & font --- DataPlotly/gui/plot_settings_widget.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DataPlotly/gui/plot_settings_widget.py b/DataPlotly/gui/plot_settings_widget.py index 0de18f95..5adabbd1 100644 --- a/DataPlotly/gui/plot_settings_widget.py +++ b/DataPlotly/gui/plot_settings_widget.py @@ -323,6 +323,7 @@ def __init__(self, mode=MODE_CANVAS, parent=None, override_iface=None, message_b self.font_xticks_color.setColor(QColor('#000000')) self.font_ylabel_color.setColor(QColor('#000000')) self.font_yticks_color.setColor(QColor('#000000')) + self.font_legend_color.setColor(QColor('#000000')) # default fonts self.font_title_style.setCurrentFont(QFont('Arial', 10)) @@ -330,6 +331,7 @@ def __init__(self, mode=MODE_CANVAS, parent=None, override_iface=None, message_b self.font_xticks_style.setCurrentFont(QFont('Arial', 10)) self.font_ylabel_style.setCurrentFont(QFont('Arial', 10)) self.font_yticks_style.setCurrentFont(QFont('Arial', 10)) + self.font_legend_style.setCurrentFont(QFont('Arial', 10)) # set range of axis min/max spin boxes self.x_axis_min.setRange(sys.float_info.max * -1, sys.float_info.max) From 8cb6faaeaa94c83727a2c4e8f8e59706018f2771 Mon Sep 17 00:00:00 2001 From: Sophie Aubier Date: Tue, 30 Sep 2025 14:49:46 +0200 Subject: [PATCH 4/4] manage the label and title customization --- DataPlotly/core/plot_types/polar.py | 17 ++++++++++++++++- DataPlotly/gui/plot_settings_widget.py | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/DataPlotly/core/plot_types/polar.py b/DataPlotly/core/plot_types/polar.py index 963e1ec9..794e80e4 100644 --- a/DataPlotly/core/plot_types/polar.py +++ b/DataPlotly/core/plot_types/polar.py @@ -59,5 +59,20 @@ def create_layout(settings): layout = super(PolarChartFactory, PolarChartFactory).create_layout(settings) layout['polar'] = settings.layout['polar'] - + layout['polar'].update({ + 'radialaxis': { + 'tickfont':{ + "size": settings.layout.get('font_xticks_size',30), + "color": settings.layout.get('font_xticks_color',"#00000"), + "family": settings.layout.get('font_xticks_family', "Arial"), + } + }, + 'angularaxis':{ + 'tickfont':{ + "size": settings.layout.get('font_yticks_size',30), + "color": settings.layout.get('font_yticks_color',"#00000"), + "family": settings.layout.get('font_yticks_family', "Arial") + } + } + }) return layout diff --git a/DataPlotly/gui/plot_settings_widget.py b/DataPlotly/gui/plot_settings_widget.py index 5adabbd1..81155161 100644 --- a/DataPlotly/gui/plot_settings_widget.py +++ b/DataPlotly/gui/plot_settings_widget.py @@ -931,23 +931,23 @@ def refreshWidgets(self): # pylint: disable=too-many-statements,too-many-branch self.plot_title_line: ['all'], self.plot_title_defined_button: ['all'], self.font_title_label: ['all'], - self.font_xlabel_label: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], - self.font_xticks_label: ['all'], - self.font_ylabel_label: ['all'], - self.font_yticks_label: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], + self.font_xlabel_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_xticks_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar','radar', 'violin'], + self.font_ylabel_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_yticks_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar','radar', 'violin'], self.font_legend_label: ['all'], self.font_title_style: ['all'], - self.font_xlabel_style: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], - self.font_xticks_style: ['all'], - self.font_ylabel_style: ['all'], - self.font_yticks_style: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], + self.font_xlabel_style: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_xticks_style: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar', 'radar', 'violin'], + self.font_ylabel_style: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_yticks_style: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar','radar', 'violin'], self.font_legend_style: ['all'], self.font_title_color: ['all'], - self.font_xlabel_color: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], - self.font_xticks_color: ['all'], + self.font_xlabel_color: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_xticks_color: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar','radar', 'violin'], self.font_legend_color: ['all'], - self.font_ylabel_color: ['all'], - self.font_yticks_color: ['scatter', 'bar', 'box', 'pie', '2dhistogram','histogram', 'polar','ternary', 'contour', 'violin'], + self.font_ylabel_color: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'violin'], + self.font_yticks_color: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'polar','radar', 'violin'], self.x_axis_label: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'ternary', 'violin'], self.x_axis_title: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'ternary', 'violin'], self.x_axis_title_defined_button: ['scatter', 'bar', 'box', 'histogram', '2dhistogram', 'ternary', 'violin'],