MCPcopy Index your code
hub / github.com/plotly/plotly.py / create_distplot

Function create_distplot

plotly/figure_factory/_distplot.py:48–258  ·  view source on GitHub ↗

Function that creates a distplot similar to seaborn.distplot; **this function is deprecated**, use instead :mod:`plotly.express` functions, for example >>> import plotly.express as px >>> tips = px.data.tips() >>> fig = px.histogram(tips, x="total_bill", y="tip", color="sex

(
    hist_data,
    group_labels,
    bin_size=1.0,
    curve_type="kde",
    colors=None,
    rug_text=None,
    histnorm=DEFAULT_HISTNORM,
    show_hist=True,
    show_curve=True,
    show_rug=True,
)

Source from the content-addressed store, hash-verified

46
47
48def create_distplot(
49 hist_data,
50 group_labels,
51 bin_size=1.0,
52 curve_type="kde",
53 colors=None,
54 rug_text=None,
55 histnorm=DEFAULT_HISTNORM,
56 show_hist=True,
57 show_curve=True,
58 show_rug=True,
59):
60 """
61 Function that creates a distplot similar to seaborn.distplot;
62 **this function is deprecated**, use instead :mod:`plotly.express`
63 functions, for example
64
65 >>> import plotly.express as px
66 >>> tips = px.data.tips()
67 >>> fig = px.histogram(tips, x="total_bill", y="tip", color="sex", marginal="rug",
68 ... hover_data=tips.columns)
69 >>> fig.show()
70
71
72 The distplot can be composed of all or any combination of the following
73 3 components: (1) histogram, (2) curve: (a) kernel density estimation
74 or (b) normal curve, and (3) rug plot. Additionally, multiple distplots
75 (from multiple datasets) can be created in the same plot.
76
77 :param (list[list]) hist_data: Use list of lists to plot multiple data
78 sets on the same plot.
79 :param (list[str]) group_labels: Names for each data set.
80 :param (list[float]|float) bin_size: Size of histogram bins.
81 Default = 1.
82 :param (str) curve_type: 'kde' or 'normal'. Default = 'kde'
83 :param (str) histnorm: 'probability density' or 'probability'
84 Default = 'probability density'
85 :param (bool) show_hist: Add histogram to distplot? Default = True
86 :param (bool) show_curve: Add curve to distplot? Default = True
87 :param (bool) show_rug: Add rug to distplot? Default = True
88 :param (list[str]) colors: Colors for traces.
89 :param (list[list]) rug_text: Hovertext values for rug_plot,
90 :return (dict): Representation of a distplot figure.
91
92 Example 1: Simple distplot of 1 data set
93
94 >>> from plotly.figure_factory import create_distplot
95
96 >>> hist_data = [[1.1, 1.1, 2.5, 3.0, 3.5,
97 ... 3.5, 4.1, 4.4, 4.5, 4.5,
98 ... 5.0, 5.0, 5.2, 5.5, 5.5,
99 ... 5.5, 5.5, 5.5, 6.1, 7.0]]
100 >>> group_labels = ['distplot example']
101 >>> fig = create_distplot(hist_data, group_labels)
102 >>> fig.show()
103
104
105 Example 2: Two data sets and added rug text

Callers 1

create_distplotMethod · 0.90

Calls 6

validate_distplotFunction · 0.85
_DistplotClass · 0.85
make_histMethod · 0.80
make_normalMethod · 0.80
make_kdeMethod · 0.80
make_rugMethod · 0.80

Tested by

no test coverage detected