MCPcopy Create free account
hub / github.com/spotify/chartify / histogram

Method histogram

chartify/_core/plot.py:674–784  ·  view source on GitHub ↗

Histogram. Args: data_frame (pandas.DataFrame): Data source for the plot. values_column (str): Column of numeric values. color_column (str, optional): Column name to group by on the color dimension. color_order (list, optional)

(
        self,
        data_frame,
        values_column,
        color_column=None,
        color_order=None,
        method="count",
        bins="auto",
    )

Source from the content-addressed store, hash-verified

672 # set(inherited_public_methods))
673
674 def histogram(
675 self,
676 data_frame,
677 values_column,
678 color_column=None,
679 color_order=None,
680 method="count",
681 bins="auto",
682 ):
683 """Histogram.
684
685 Args:
686 data_frame (pandas.DataFrame): Data source for the plot.
687 values_column (str): Column of numeric values.
688 color_column (str, optional): Column name to group by on
689 the color dimension.
690 color_order (list, optional): List of values within the
691 'color_column' for specific sorting of the colors.
692 method (str, optional):
693 - 'count': Result will contain the number of samples at each bin.
694 - 'density': Result is the value of the probability density
695 function at each bin.
696 The PDF is normalized so that the integral over the range is 1.
697 - 'mass': Result is the value of the probability mass
698 function at each bin.
699 The PMF is normalized so that the value is equivalent to
700 the sample count at each bin divided by the total count.
701 bins (int or sequence of scalars or str, optional):
702 If bins is an int, it defines the number of equal-width
703 bins in the given range.
704 If bins is a sequence, it defines the bin edges,
705 including the rightmost edge, allowing for non-uniform
706 bin widths. See numpy.histogram documentation for more details.
707 - ‘auto’:
708 Maximum of the ‘sturges’ and ‘fd’ estimators.
709 Provides good all around performance.
710 - ‘fd’ (Freedman Diaconis Estimator)
711 Robust (resilient to outliers) estimator that takes into
712 account data variability and data size.
713 - ‘doane’
714 An improved version of Sturges’ estimator that works
715 better with non-normal datasets.
716 - ‘scott’
717 Less robust estimator that that takes into account data
718 variability and data size.
719 - ‘rice’
720 Estimator does not take variability into account, only
721 data size. Commonly overestimates number of bins required.
722 - ‘sturges’
723 R’s default method, only accounts for data size.
724 Only optimal for gaussian data and underestimates number
725 of bins for large non-gaussian datasets.
726 - ‘sqrt’
727 Square root (of data size) estimator, used by Excel and
728 other programs for its speed and simplicity.
729 """
730 vertical = self._chart.axes._vertical
731

Callers 5

_histogram_exampleFunction · 0.80
_histogram_example2Function · 0.80
_kde_example2Function · 0.80
test_histogramMethod · 0.80

Calls 4

_get_color_and_orderMethod · 0.80
_plot_with_legendMethod · 0.80
_apply_settingsMethod · 0.80

Tested by 2

test_histogramMethod · 0.64