#NEWLINE# def violinplot( data , ax = None , labels = None , positions = None , side = 'both' , show_boxplot = True , plot_opts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# 'Make a violin plot of each dataset in the `data` sequence.\n\n    A violin plot is a boxplot combined with a kernel density estimate of the\n    probability density function per point.\n\n    Parameters\n    ----------\n    data : sequence of ndarrays\n        Data arrays, one array per value in `positions`.\n    ax : Matplotlib AxesSubplot instance, optional\n        If given, this subplot is used to plot in instead of a new figure being\n        created.\n    labels : list of str, optional\n        Tick labels for the horizontal axis.  If not given, integers\n        ``1..len(data)`` are used.\n    positions : array_like, optional\n        Position array, used as the horizontal axis of the plot.  If not given,\n        spacing of the violins will be equidistant.\n    side : {\'both\', \'left\', \'right\'}, optional\n        How to plot the violin.  Default is \'both\'.  The \'left\', \'right\'\n        options can be used to create asymmetric violin plots.\n    show_boxplot : bool, optional\n        Whether or not to show normal box plots on top of the violins.\n        Default is True.\n    plot_opts : dict, optional\n        A dictionary with plotting options.  Any of the following can be\n        provided, if not present in `plot_opts` the defaults will be used::\n\n          - \'violin_fc\', MPL color.  Fill color for violins.  Default is \'y\'.\n          - \'violin_ec\', MPL color.  Edge color for violins.  Default is \'k\'.\n          - \'violin_lw\', scalar.  Edge linewidth for violins.  Default is 1.\n          - \'violin_alpha\', float.  Transparancy of violins.  Default is 0.5.\n          - \'cutoff\', bool.  If True, limit violin range to data range.\n                Default is False.\n          - \'cutoff_val\', scalar.  Where to cut off violins if `cutoff` is\n                True.  Default is 1.5 standard deviations.\n          - \'cutoff_type\', {\'std\', \'abs\'}.  Whether cutoff value is absolute,\n                or in standard deviations.  Default is \'std\'.\n          - \'violin_width\' : float.  Relative width of violins.  Max available\n                space is 1, default is 0.8.\n          - \'label_fontsize\', MPL fontsize.  Adjusts fontsize only if given.\n          - \'label_rotation\', scalar.  Adjusts label rotation only if given.\n                Specify in degrees.\n\n    Returns\n    -------\n    fig : Matplotlib figure instance\n        If `ax` is None, the created figure.  Otherwise the figure to which\n        `ax` is connected.\n\n    See Also\n    --------\n    beanplot : Bean plot, builds on `violinplot`.\n    matplotlib.pyplot.boxplot : Standard boxplot.\n\n    Notes\n    -----\n    The appearance of violins can be customized with `plot_opts`.  If\n    customization of boxplot elements is required, set `show_boxplot` to False\n    and plot it on top of the violins by calling the Matplotlib `boxplot`\n    function directly.  For example::\n\n        violinplot(data, ax=ax, show_boxplot=False)\n        ax.boxplot(data, sym=\'cv\', whis=2.5)\n\n    It can happen that the axis labels or tick labels fall outside the plot\n    area, especially with rotated labels on the horizontal axis.  With\n    Matplotlib 1.1 or higher, this can easily be fixed by calling\n    ``ax.tight_layout()``.  With older Matplotlib one has to use ``plt.rc`` or\n    ``plt.rcParams`` to fix this, for example::\n\n        plt.rc(\'figure.subplot\', bottom=0.25)\n        violinplot(data, ax=ax)\n\n    References\n    ----------\n    J.L. Hintze and R.D. Nelson, "Violin Plots: A Box Plot-Density Trace\n    Synergism", The American Statistician, Vol. 52, pp.181-84, 1998.\n\n    Examples\n    --------\n    We use the American National Election Survey 1996 dataset, which has Party\n    Identification of respondents as independent variable and (among other\n    data) age as dependent variable.\n\n    >>> data = sm.datasets.anes96.load_pandas()\n    >>> party_ID = np.arange(7)\n    >>> labels = ["Strong Democrat", "Weak Democrat", "Independent-Democrat",\n    ...           "Independent-Indpendent", "Independent-Republican",\n    ...           "Weak Republican", "Strong Republican"]\n\n    Group age by party ID, and create a violin plot with it:\n\n    >>> plt.rcParams[\'figure.subplot.bottom\'] = 0.23  # keep labels visible\n    >>> age = [data.exog[\'age\'][data.endog == id] for id in party_ID]\n    >>> fig = plt.figure()\n    >>> ax = fig.add_subplot(111)\n    >>> sm.graphics.violinplot(age, ax=ax, labels=labels,\n    ...                        plot_opts={\'cutoff_val\':5, \'cutoff_type\':\'abs\',\n    ...                                   \'label_fontsize\':\'small\',\n    ...                                   \'label_rotation\':30})\n    >>> ax.set_xlabel("Party identification of respondent.")\n    >>> ax.set_ylabel("Age")\n    >>> plt.show()\n\n    .. plot:: plots/graphics_boxplot_violinplot.py\n\n    ' #NEWLINE# ( fig , ax ) = utils . create_mpl_ax ( ax ) #NEWLINE# if ( positions is None ) : #NEWLINE# #INDENT# positions = ( np . arange ( len ( data ) ) + 1 ) #NEWLINE# #UNINDENT# pos_span = ( np . max ( positions ) - np . min ( positions ) ) #NEWLINE# width = np . min ( [ ( 0.15 * np . max ( [ pos_span , 1.0 ] ) ) , ( plot_opts . get ( 'violin_width' , 0.8 ) / 2.0 ) ] ) #NEWLINE# for ( pos_data , pos ) in zip ( data , positions ) : #NEWLINE# #INDENT# ( xvals , violin ) = _single_violin ( ax , pos , pos_data , width , side , plot_opts ) #NEWLINE# #UNINDENT# if show_boxplot : #NEWLINE# #INDENT# ax . boxplot ( data , notch = 1 , positions = positions , vert = 1 ) #NEWLINE# #UNINDENT# _set_ticks_labels ( ax , data , labels , positions , plot_opts ) #NEWLINE# return side