PieChart

Qualified name: manimextra.diagrams.PieChart

class manimextra.diagrams.PieChart(data, labels=None, label_buff=0.85, colors=[ManimColor('#FC6255'), ManimColor('#83C167'), ManimColor('#58C4DD'), ManimColor('#C55F73'), ManimColor('#FFFF00'), ManimColor('#5CD0B3')], inner_radius=1, outer_radius=2)

Bases: VGroup

A pie chart.

Parameters:
  • data (Union[dict, tuple]) – The data of the pie chart. If it is a dictionary, the keys are the labels and the values are the values. If it is a tuple, the first element is the labels and the second element is the values.

  • labels (Optional[List[str]]) – The labels of the pie chart.

  • label_buff (float, optional) – The buffer between the label and the sector. Default to 0.85.

  • colors (List[Union[str, Tuple[float, float, float]]], optional) – The colors of the sectors. Default to PIE_CHART_COLORS.

  • inner_radius (float, optional) – The inner radius of the sectors. Default to 1.

  • outer_radius (float, optional) – The outer radius of the sectors. Default to 2.

Examples

Example: PieChartExample

../_images/PieChartExample-1.png
from manim import *
from manimextra import *

class PieChartExample(Scene):
    def construct(self):
        pie_chart = PieChart(
            data={"First": 10, "Second": 20, "Third": 30},
            label_buff=0.7,
            inner_radius=1,
            outer_radius=2
        )
        self.add(pie_chart)

Methods

get_labels

get_sector

Get a sector by value or label.

get_sectors

Attributes

animate

Used to animate the application of any method of self.

animation_overrides

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

n_points_per_curve

sheen_factor

stroke_color

width

The width of the mobject.

_original__init__(data, labels=None, label_buff=0.85, colors=[ManimColor('#FC6255'), ManimColor('#83C167'), ManimColor('#58C4DD'), ManimColor('#C55F73'), ManimColor('#FFFF00'), ManimColor('#5CD0B3')], inner_radius=1, outer_radius=2)

Initialize self. See help(type(self)) for accurate signature.

get_sector(value=None, label=None)

Get a sector by value or label.

Parameters:
  • value

  • label

Returns: