Skip to content

Add option to add ticks on x-axis in BarChart()#1694

Merged
3b1b merged 3 commits into3b1b:masterfrom
DangGiaChi:BarChart_modified
Dec 17, 2021
Merged

Add option to add ticks on x-axis in BarChart()#1694
3b1b merged 3 commits into3b1b:masterfrom
DangGiaChi:BarChart_modified

Conversation

@DangGiaChi
Copy link
Contributor

Motivation

It's only a minor change. I found out that BarChart() doesn't have an option to add ticks on x-axis. I know it's because the x-axis is usually for names or labels and not values, but I think it's nice to add an option to add ticks to seperate bars for better visualization.

Proposed changes

  • I looked up at how manim add ticks on y-axis and created an option for people to also add ticks to the x-axis
  • I added a config parameter "include-x-ticks"
  • The number of ticks divided is also the number of values

Test

Code:

from manimlib import *

class Test(Scene):
    def construct(self):
        global chart
        bar_value = [50]*10
        chart = BarChart(
            bar_value,
            label_y_axis = True,
            n_ticks = 10,
            max_value = 100,
            bar_label_scale_val = 0.5,
            include_x_ticks = True
        )
        self.add(chart)

Result
Test
:

Copy link
Collaborator

@TonyCrane TonyCrane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some suggestions. Hope you can improve them :)

@DangGiaChi
Copy link
Contributor Author

Okok, I'll check it out as soon as it's morning at my place:)

@TonyCrane TonyCrane requested a review from 3b1b December 17, 2021 08:05
@3b1b 3b1b merged commit 37b63ca into 3b1b:master Dec 17, 2021
TonyCrane added a commit that referenced this pull request Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants