From 857206a9b6654a2dcad2669339a36fece64feb3a Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 31 Jan 2022 10:52:53 +0200 Subject: [PATCH] Fix extra_layout not passed to report_matrix (#559) --- clearml/logger.py | 9 +++++++++ clearml/utilities/plotly_reporter.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clearml/logger.py b/clearml/logger.py index 19e68e99..375bf4f3 100644 --- a/clearml/logger.py +++ b/clearml/logger.py @@ -211,6 +211,7 @@ class Logger(object): :param yaxis: The y-axis title. (Optional) :param mode: Multiple histograms mode, stack / group / relative. Default is 'group'. :param extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/bar/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ self._touch_title_series(title, series) @@ -257,6 +258,7 @@ class Logger(object): :param yaxis: The y-axis title. (Optional) :param mode: Multiple histograms mode, stack / group / relative. Default is 'group'. :param extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/bar/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ @@ -319,6 +321,7 @@ class Logger(object): :param csv: path to local csv file :param url: A URL to the location of csv file. :param extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/table/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ mutually_exclusive( @@ -394,6 +397,7 @@ class Logger(object): :param str comment: A comment displayed with the plot, underneath the title. :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/scatter/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ @@ -471,6 +475,7 @@ class Logger(object): :param str comment: A comment displayed with the plot, underneath the title. :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/scatter/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ @@ -549,6 +554,7 @@ class Logger(object): :param str comment: A comment displayed with the plot, underneath the title. :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/scatter3d/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ # check if multiple series @@ -629,6 +635,7 @@ class Logger(object): :param bool yaxis_reversed: If False 0,0 is at the bottom left corner. If True 0,0 is at the Top left corner :param str comment: A comment displayed with the plot, underneath the title. :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/heatmap/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ @@ -682,6 +689,7 @@ class Logger(object): :param list(str) ylabels: Labels for each row of the matrix. (Optional) :param bool yaxis_reversed: If False 0,0 is at the bottom left corner. If True 0,0 is at the Top left corner :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/heatmap/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ self._touch_title_series(title, series) @@ -730,6 +738,7 @@ class Logger(object): :param list(float) camera: X,Y,Z coordinates indicating the camera position. The default value is ``(1,1,1)``. :param str comment: A comment displayed with the plot, underneath the title. :param dict extra_layout: optional dictionary for layout configuration, passed directly to plotly + See full details on the supported configuration: https://plotly.com/javascript/reference/surface/ example: extra_layout={'xaxis': {'type': 'date', 'range': ['2020-01-01', '2020-01-31']}} """ diff --git a/clearml/utilities/plotly_reporter.py b/clearml/utilities/plotly_reporter.py index 6d1e3887..e04f6ca8 100644 --- a/clearml/utilities/plotly_reporter.py +++ b/clearml/utilities/plotly_reporter.py @@ -250,12 +250,13 @@ def create_value_matrix(np_value_matrix, title="Heatmap Matrix", xlabels=None, y if yaxis_reversed: conf_matrix_plot['layout']['yaxis']['autorange'] = "reversed" - if custom_colors: + if custom_colors and not layout_config: scale, bar = _get_z_colorbar_data() conf_matrix_plot["data"][0].update({"colorscale": scale}) conf_matrix_plot["data"][0].update({"colorbar": bar}) if layout_config: + conf_matrix_plot["data"][0] = merge_dicts(conf_matrix_plot["data"][0], layout_config) conf_matrix_plot["layout"] = merge_dicts(conf_matrix_plot["layout"], layout_config) return conf_matrix_plot