@@ -194,8 +194,8 @@ def violinplot(vals, fillcolor='#1f77b4', rugplot=True):
194194
195195
196196def violin_no_colorscale (data , data_header , group_header , colors ,
197- use_colorscale , group_stats ,
198- height , width , title ):
197+ use_colorscale , group_stats , rugplot ,
198+ height , width , title ):
199199 """
200200 Refer to FigureFactory.create_violin() for docstring.
201201
@@ -223,7 +223,8 @@ def violin_no_colorscale(data, data_header, group_header, colors,
223223 if color_index >= len (colors ):
224224 color_index = 0
225225 plot_data , plot_xrange = violinplot (vals ,
226- fillcolor = colors [color_index ])
226+ fillcolor = colors [color_index ],
227+ rugplot = rugplot )
227228 layout = graph_objs .Layout ()
228229
229230 for item in plot_data :
@@ -250,7 +251,7 @@ def violin_no_colorscale(data, data_header, group_header, colors,
250251
251252
252253def violin_colorscale (data , data_header , group_header , colors , use_colorscale ,
253- group_stats , height , width , title ):
254+ group_stats , rugplot , height , width , title ):
254255 """
255256 Refer to FigureFactory.create_violin() for docstring.
256257
@@ -303,7 +304,8 @@ def violin_colorscale(data, data_header, group_header, colors, use_colorscale,
303304
304305 plot_data , plot_xrange = violinplot (
305306 vals ,
306- fillcolor = 'rgb{}' .format (intermed_color )
307+ fillcolor = 'rgb{}' .format (intermed_color ),
308+ rugplot = rugplot
307309 )
308310 layout = graph_objs .Layout ()
309311
@@ -343,7 +345,7 @@ def violin_colorscale(data, data_header, group_header, colors, use_colorscale,
343345
344346
345347def violin_dict (data , data_header , group_header , colors , use_colorscale ,
346- group_stats , height , width , title ):
348+ group_stats , rugplot , height , width , title ):
347349 """
348350 Refer to FigureFactory.create_violin() for docstring.
349351
@@ -375,7 +377,8 @@ def violin_dict(data, data_header, group_header, colors, use_colorscale,
375377
376378 for k , gr in enumerate (group_name ):
377379 vals = np .asarray (gb .get_group (gr )[data_header ], np .float )
378- plot_data , plot_xrange = violinplot (vals , fillcolor = colors [gr ])
380+ plot_data , plot_xrange = violinplot (vals , fillcolor = colors [gr ],
381+ rugplot = rugplot )
379382 layout = graph_objs .Layout ()
380383
381384 for item in plot_data :
@@ -401,18 +404,18 @@ def violin_dict(data, data_header, group_header, colors, use_colorscale,
401404
402405
403406def create_violin (data , data_header = None , group_header = None , colors = None ,
404- use_colorscale = False , group_stats = None , height = 450 ,
405- width = 600 , title = 'Violin and Rug Plot' ):
407+ use_colorscale = False , group_stats = None , rugplot = True ,
408+ height = 450 , width = 600 , title = 'Violin and Rug Plot' ):
406409 """
407410 Returns figure for a violin plot
408411
409412 :param (list|array) data: accepts either a list of numerical values,
410413 a list of dictionaries all with identical keys and at least one
411414 column of numeric values, or a pandas dataframe with at least one
412- column of numbers
415+ column of numbers.
413416 :param (str) data_header: the header of the data column to be used
414417 from an inputted pandas dataframe. Not applicable if 'data' is
415- a list of numeric values
418+ a list of numeric values.
416419 :param (str) group_header: applicable if grouping data by a variable.
417420 'group_header' must be set to the name of the grouping variable.
418421 :param (str|tuple|list|dict) colors: either a plotly scale name,
@@ -422,18 +425,19 @@ def create_violin(data, data_header=None, group_header=None, colors=None,
422425 tuple of the form (a, b, c) where a, b and c belong to [0, 1].
423426 If colors is a list, it must contain valid color types as its
424427 members.
425- :param (bool) use_colorscale: Only applicable if grouping by another
428+ :param (bool) use_colorscale: only applicable if grouping by another
426429 variable. Will implement a colorscale based on the first 2 colors
427430 of param colors. This means colors must be a list with at least 2
428431 colors in it (Plotly colorscales are accepted since they map to a
429- list of two rgb colors)
432+ list of two rgb colors).
430433 :param (dict) group_stats: a dictioanry where each key is a unique
431434 value from the group_header column in data. Each value must be a
432435 number and will be used to color the violin plots if a colorscale
433- is being used
434- :param (float) height: the height of the violin plot
435- :param (float) width: the width of the violin plot
436- :param (str) title: the title of the violin plot
436+ is being used.
437+ :param (bool) rugplot: determines if a rugplot is draw on violin plot.
438+ :param (float) height: the height of the violin plot.
439+ :param (float) width: the width of the violin plot.
440+ :param (str) title: the title of the violin plot.
437441
438442 Example 1: Single Violin Plot
439443 ```
@@ -558,7 +562,8 @@ def create_violin(data, data_header=None, group_header=None, colors=None,
558562 data = data [data_header ].values .tolist ()
559563
560564 # call the plotting functions
561- plot_data , plot_xrange = violinplot (data , fillcolor = valid_colors [0 ])
565+ plot_data , plot_xrange = violinplot (data , fillcolor = valid_colors [0 ],
566+ rugplot = rugplot )
562567
563568 layout = graph_objs .Layout (
564569 title = title ,
@@ -596,13 +601,13 @@ def create_violin(data, data_header=None, group_header=None, colors=None,
596601 # validate colors dict choice below
597602 fig = violin_dict (
598603 data , data_header , group_header , valid_colors ,
599- use_colorscale , group_stats , height , width , title
604+ use_colorscale , group_stats , rugplot , height , width , title
600605 )
601606 return fig
602607 else :
603608 fig = violin_no_colorscale (
604609 data , data_header , group_header , valid_colors ,
605- use_colorscale , group_stats , height , width , title
610+ use_colorscale , group_stats , rugplot , height , width , title
606611 )
607612 return fig
608613 else :
@@ -622,6 +627,6 @@ def create_violin(data, data_header=None, group_header=None, colors=None,
622627
623628 fig = violin_colorscale (
624629 data , data_header , group_header , valid_colors ,
625- use_colorscale , group_stats , height , width , title
630+ use_colorscale , group_stats , rugplot , height , width , title
626631 )
627632 return fig
0 commit comments