dexplo / bar_chart_race

Create animated bar chart races in Python with matplotlib
MIT License
1.35k stars 351 forks source link

Shaking of Y Ticks and Y-Axis #49

Open samueltjsun opened 3 years ago

samueltjsun commented 3 years ago

Hey Guys!

First of all, thank you so much for your effort with this great tool!

The issue is basically described in the subject. The y-axis labels of all my plots are shaking if any label has a different number of strings and changes the order while racing.

For instance, I have 40 data and I choose the top 10. In the beginning, the longest string is "UC Browser" in the screenshot. Therefore, the y-label space on the left-hand side uses "UC Browser" to calculate the space. However, after a few seconds, the "360 Safe Browser" is in the top 10. But the string length is longer than the previous one. I guess it causes the different sizes of the plot and the width of the x-axis, and it will shake after it generates the animation. Please kindly refer to the below image.

Issue_BarChartRace (1)

Do you have any idea how to fix the position of the y-axis or the width of the x-axis? Or can we get the longest string number throughout all data and use it to set up space on the left-hand side even that label is not in the top 10 rankings?

Feel free to let me know if you have any suggestions. I truly appreciate your assistance.

samueltjsun commented 3 years ago

image image

Hi Guys,

I think it's because, during the animation when the bars switch the order, I don't know somehow the name contains the longest words was disappeared. The figure size has been changed too. In this example, if it changes the order of "XLRE", it's disappeared during the transition. So the different sizes of plots will let the animation looks like the shaking of the y axis.

Do you have any idea how to solve this issue? Feel free to let me know if you have any suggestions.

Thank you!