马尼姆对角线 bar_names

Manim Diagonal bar_names

我想在 manim 中制作条形图的动画,效果很好。但是,bar_names 很长,必须显示得相当小。有没有办法旋转它们,使它们显示得更大?


    CONFIG = {
        "max_value" : 100,
        "bar_names" : ["Fleisch von Wiederkäuern","Anderes Fleisch, Fisch","Milchprodukte","Früchte", "Snacks, etc.","Gemüse","Pflanzliche Öle","Getreideprodukte", "Pflanzliche Proteine"],
        "bar_label_scale_val" : 0.2,
        "bar_stroke_width" : 0,
        "width" : 10,
        "height" : 6,
        "label_y_axis" : False,

    }
    def construct(self):

        composition = [96.350861, 18.5706488, 14.7071608, 8.25588773, 7.33856028, 4.24083463, 1.65574964, 1.36437485, 1]
        chart = BarChart(values=composition, **self.CONFIG)
        self.play(Write(chart), run_time=2)```

也许是这样的? (我刚刚制作了新标签,所以删除旧标签,或者删除它们的大小) (我还修改了一些名称,因为我的 Latex 因某些字符而崩溃)

CONFIG = {
        "height": 4,
        "width": 10,
        "n_ticks": 4,
        "tick_width": 0.2,
        "label_y_axis": False,
        "y_axis_label_height": 0.25,
        "max_value": 100,
        "bar_colors": [BLUE, YELLOW],
        "bar_fill_opacity": 0.8,
        "bar_stroke_width": 0,
        "bar_names": ["Fleisch von Wiederkuern","Anderes Fleisch, Fisch","Milchprodukte","Frchte", "Snacks, etc.","Gemse","Pflanzliche le","Getreideprodukte", "Pflanzliche Proteine"],
        "bar_label_scale_val": 0


    }
    def construct(self):
        bar_names=["Fleisch von Wiederkuern","Anderes Fleisch, Fisch","Milchprodukte","Frchte", "Snacks, etc.","Gemse","Pflanzliche le","Getreideprodukte", "Pflanzliche Proteine"]
        Lsize=0.55
        Lseparation=1.1
        Lpositionx=-5.4
        Lpositiony=2
        bar_labels = VGroup()
        for i in range(len(bar_names)):
            label = TexMobject(bar_names[i])
            label.scale(Lsize)
            label.move_to(DOWN*Lpositiony+(i*Lseparation+Lpositionx)*RIGHT)
            label.rotate(np.pi*(1.5/6))
            bar_labels.add(label)
            
        
        composition = [96.350861, 18.5706488, 14.7071608, 8.25588773, 7.33856028, 4.24083463, 1.65574964, 1.36437485, 1]
        chart = BarChart(values=composition, **self.CONFIG)
        chart.shift(UP)
        self.play(Write(chart),Write(bar_labels), run_time=2)
# Manim Community Version 0.7.0 in Google Colab

%%manim -qm -v WARNING BarChartExample2

import numpy as np
mobject.probability.np = np

class BarChartExample2(Scene):
  CONFIG = {
        "height": 4,
        "width": 10,
        "n_ticks": 4,
        "tick_width": 0.2,
        "label_y_axis": False,
        "y_axis_label_height": 0.25,
        "max_value": 100,
        "bar_colors": [BLUE, YELLOW],
        "bar_fill_opacity": 0.8,
        "bar_stroke_width": 0,
        "bar_names": ["Fleisch von Wiederkuern","Anderes Fleisch, Fisch","Milchprodukte",
                      "Frchte", "Snacks, etc.","Gemse","Pflanzliche le","Getreideprodukte", "Pflanzliche Proteine"],
        "bar_label_scale_val": 0
  }

  def construct(self):
        bar_names=["Fleisch von Wiederkuern","Anderes Fleisch, Fisch","Milchprodukte",
                   "Frchte", "Snacks, etc.","Gemse","Pflanzliche le","Getreideprodukte", "Pflanzliche Proteine"]
        Lsize=0.55
        Lseparation=1.1
        Lpositionx=-5.4
        Lpositiony=2
        bar_labels = VGroup()
        for i in range(len(bar_names)):
            #label = TexMobject(bar_names[i])
            label = MathTex(bar_names[i])
            label.scale(Lsize)
            label.move_to(DOWN*Lpositiony+(i*Lseparation+Lpositionx)*RIGHT)
            label.rotate(np.pi*(1.5/6))
            bar_labels.add(label)
            
        composition = [96.350861, 18.5706488, 14.7071608, 8.25588773, 7.33856028, 4.24083463, 1.65574964, 1.36437485, 1]
        chart = BarChart(values=composition,**self.CONFIG)
        chart.shift(UP)
        self.play(Write(chart),Write(bar_labels), run_time=2)