BarChart

Qualified name: manim.mobject.probability.BarChart

class BarChart(values, height=4, width=6, n_ticks=4, tick_width=0.2, label_y_axis=True, y_axis_label_height=0.25, max_value=1, bar_colors=['#58C4DD', '#FFFF00'], bar_fill_opacity=0.8, bar_stroke_width=3, bar_names=[], bar_label_scale_val=0.75, **kwargs)[source]

Bases: manim.mobject.types.vectorized_mobject.VGroup

This is a class for Bar Charts.

Parameters
  • values (Iterable[float]) – The values for the bar chart.

  • height (float) – The height of the axes.

  • width (float) – The width of the axes.

  • n_ticks (int) – Number of ticks.

  • tick_width (float) – Width of the ticks.

  • label_y_axis (bool) – Y axis label

  • y_axis_label_height (float) – Height of the label.

  • max_value (float) – Maximum value of the data.

  • bar_colors – The colors of the bars.

  • bar_fill_opacity (float) – The opacity of the bars.

  • bar_stroke_width (float) – The stroke width of the bars.

  • bar_names (List[str]) – The names of each bar.

  • bar_label_scale_val (float) – The label size.

Examples

Example: BarChartExample

../_images/BarChartExample-1.png
from manim import *

class BarChartExample(Scene):
    def construct(self):
        pull_req = [54, 23, 47, 48, 40, 64, 112, 87]
        versions = [
            "v0.1.0",
            "v0.1.1",
            "v0.2.0",
            "v0.3.0",
            "v0.4.0",
            "v0.5.0",
            "v0.6.0",
            "v0.7.0",
        ]
        colors = ["#003f5c", "#58508d", "#bc5090", "#ff6361", "#ffa600"]
        bar = BarChart(
            pull_req,
            max_value=max(pull_req),
            bar_colors=colors,
            bar_names=versions,
            bar_label_scale_val=0.3,
        )
        self.add(bar)

Methods

add_axes

add_bars

change_bar_values

Attributes

animate

Used to animate the application of a method.

animation_overrides

depth

The depth of the mobject.

height

The height of the mobject.

width

The width of the mobject.