Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Dec 17, 2021

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 :)

manimlib/mobject/probability.py Outdated Show resolved Hide resolved
manimlib/mobject/probability.py Outdated Show resolved Hide resolved
@DangGiaChi
Copy link
Contributor Author

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

manimlib/mobject/probability.py Outdated Show resolved Hide resolved
@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.

None yet

3 participants