From 1f28947dd2213668ab17b966df9b66b20fd2762c Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 29 Aug 2016 15:12:28 -0400 Subject: [PATCH 1/2] add print_grid param to create_violin --- plotly/tools.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/plotly/tools.py b/plotly/tools.py index 6d5de58e3be..37ca7ccb540 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -1211,7 +1211,7 @@ def _add_domain_is_3d(layout, s_label, x_domain, y_domain): empty_str = ' (empty) ' # empty cell string # Init grid_str with intro message - grid_str = "This is the format of your plot grid:\n" + grid_str = "This is the formats of your plot grid:\n" # Init tmp list of lists of strings (sorta like 'grid_ref' but w/ strings) _tmp = [['' for c in range(cols)] for r in range(rows)] @@ -2708,7 +2708,7 @@ def _violinplot(vals, fillcolor='#1f77b4', rugplot=True): @staticmethod def _violin_no_colorscale(data, data_header, group_header, colors, use_colorscale, group_stats, - height, width, title): + height, width, title, print_grid): """ Refer to FigureFactory.create_violin() for docstring. @@ -2731,7 +2731,7 @@ def _violin_no_colorscale(data, data_header, group_header, colors, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=True) + print_grid=print_grid) color_index = 0 for k, gr in enumerate(group_name): vals = np.asarray(gb.get_group(gr)[data_header], np.float) @@ -2769,7 +2769,8 @@ def _violin_no_colorscale(data, data_header, group_header, colors, @staticmethod def _violin_colorscale(data, data_header, group_header, colors, - use_colorscale, group_stats, height, width, title): + use_colorscale, group_stats, height, width, + title, print_grid): """ Refer to FigureFactory.create_violin() for docstring. @@ -2799,7 +2800,7 @@ def _violin_colorscale(data, data_header, group_header, colors, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=True) + print_grid=print_grid) # prepare low and high color for colorscale lowcolor = FigureFactory._color_parser( @@ -2870,7 +2871,7 @@ def _violin_colorscale(data, data_header, group_header, colors, @staticmethod def _violin_dict(data, data_header, group_header, colors, use_colorscale, - group_stats, height, width, title): + group_stats, height, width, title, print_grid): """ Refer to FigureFactory.create_violin() for docstring. @@ -2900,7 +2901,7 @@ def _violin_dict(data, data_header, group_header, colors, use_colorscale, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=True) + print_grid=print_grid) for k, gr in enumerate(group_name): vals = np.asarray(gb.get_group(gr)[data_header], np.float) @@ -2936,7 +2937,8 @@ def _violin_dict(data, data_header, group_header, colors, use_colorscale, @staticmethod def create_violin(data, data_header=None, group_header=None, colors=None, use_colorscale=False, group_stats=None, - height=450, width=600, title='Violin and Rug Plot'): + height=450, width=600, title='Violin and Rug Plot', + print_grid=True): """ Returns figure for a violin plot @@ -2968,6 +2970,8 @@ def create_violin(data, data_header=None, group_header=None, :param (float) height: the height of the violin plot :param (float) width: the width of the violin plot :param (str) title: the title of the violin plot + :param (str) print_grid: determines if make_subplots() returns a + printed string displaying the rows/columns dimensions Example 1: Single Violin Plot ``` @@ -3134,13 +3138,15 @@ def create_violin(data, data_header=None, group_header=None, # validate colors dict choice below fig = FigureFactory._violin_dict( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title + use_colorscale, group_stats, height, width, title, + print_grid ) return fig else: fig = FigureFactory._violin_no_colorscale( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title + use_colorscale, group_stats, height, width, title, + print_grid ) return fig else: @@ -3160,7 +3166,8 @@ def create_violin(data, data_header=None, group_header=None, fig = FigureFactory._violin_colorscale( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title + use_colorscale, group_stats, height, width, title, + print_grid ) return fig From 8626d6df84722e95b86f088de229d61dcc059930 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Wed, 7 Sep 2016 13:02:41 -0400 Subject: [PATCH 2/2] implicitly turn off print_grid display for Violin only --- plotly/tools.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/plotly/tools.py b/plotly/tools.py index 37ca7ccb540..57db7a7573c 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -1211,7 +1211,7 @@ def _add_domain_is_3d(layout, s_label, x_domain, y_domain): empty_str = ' (empty) ' # empty cell string # Init grid_str with intro message - grid_str = "This is the formats of your plot grid:\n" + grid_str = "This is the format of your plot grid:\n" # Init tmp list of lists of strings (sorta like 'grid_ref' but w/ strings) _tmp = [['' for c in range(cols)] for r in range(rows)] @@ -2708,7 +2708,7 @@ def _violinplot(vals, fillcolor='#1f77b4', rugplot=True): @staticmethod def _violin_no_colorscale(data, data_header, group_header, colors, use_colorscale, group_stats, - height, width, title, print_grid): + height, width, title): """ Refer to FigureFactory.create_violin() for docstring. @@ -2731,7 +2731,7 @@ def _violin_no_colorscale(data, data_header, group_header, colors, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=print_grid) + print_grid=False) color_index = 0 for k, gr in enumerate(group_name): vals = np.asarray(gb.get_group(gr)[data_header], np.float) @@ -2770,7 +2770,7 @@ def _violin_no_colorscale(data, data_header, group_header, colors, @staticmethod def _violin_colorscale(data, data_header, group_header, colors, use_colorscale, group_stats, height, width, - title, print_grid): + title): """ Refer to FigureFactory.create_violin() for docstring. @@ -2800,7 +2800,7 @@ def _violin_colorscale(data, data_header, group_header, colors, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=print_grid) + print_grid=False) # prepare low and high color for colorscale lowcolor = FigureFactory._color_parser( @@ -2871,7 +2871,7 @@ def _violin_colorscale(data, data_header, group_header, colors, @staticmethod def _violin_dict(data, data_header, group_header, colors, use_colorscale, - group_stats, height, width, title, print_grid): + group_stats, height, width, title): """ Refer to FigureFactory.create_violin() for docstring. @@ -2901,7 +2901,7 @@ def _violin_dict(data, data_header, group_header, colors, use_colorscale, fig = make_subplots(rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, - print_grid=print_grid) + print_grid=False) for k, gr in enumerate(group_name): vals = np.asarray(gb.get_group(gr)[data_header], np.float) @@ -2937,8 +2937,7 @@ def _violin_dict(data, data_header, group_header, colors, use_colorscale, @staticmethod def create_violin(data, data_header=None, group_header=None, colors=None, use_colorscale=False, group_stats=None, - height=450, width=600, title='Violin and Rug Plot', - print_grid=True): + height=450, width=600, title='Violin and Rug Plot'): """ Returns figure for a violin plot @@ -2970,8 +2969,6 @@ def create_violin(data, data_header=None, group_header=None, :param (float) height: the height of the violin plot :param (float) width: the width of the violin plot :param (str) title: the title of the violin plot - :param (str) print_grid: determines if make_subplots() returns a - printed string displaying the rows/columns dimensions Example 1: Single Violin Plot ``` @@ -3138,15 +3135,13 @@ def create_violin(data, data_header=None, group_header=None, # validate colors dict choice below fig = FigureFactory._violin_dict( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title, - print_grid + use_colorscale, group_stats, height, width, title ) return fig else: fig = FigureFactory._violin_no_colorscale( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title, - print_grid + use_colorscale, group_stats, height, width, title ) return fig else: @@ -3166,8 +3161,7 @@ def create_violin(data, data_header=None, group_header=None, fig = FigureFactory._violin_colorscale( data, data_header, group_header, valid_colors, - use_colorscale, group_stats, height, width, title, - print_grid + use_colorscale, group_stats, height, width, title ) return fig