dexplo / bar_chart_race

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

X-Axis to include nagative values. It follows that "fixed_min" will be good to have. #40

Open sgangal opened 3 years ago

sgangal commented 3 years ago

Hi Ted,

Very good API ... Thanks a lot !!

I would request that you permit X-Axis to include negative values as well. If you were to include then it follows that the "fixed_min" will be good to have just like you have "fixed_max".

The use case where say I'm plotting return of a group of stocks, and some of them have negative return that I'd like to plot. (In case of Covid deaths and Home Runs it's all expressed as positive X-Axis values, however there are instances of negatives as well.) Another use case could be where we're plotting the Average Temperatures of Chicago, Houston, San Francisco, Los Angeles etc. recorded on Jan1, Feb 2, Mar 1, etc.

Thanks. ~ Salil

haemi commented 3 years ago

is there any way to achieve this? E.g. through normalizing the data and then changing the bar values?

bzimons commented 3 years ago

I did something similar: My data was time stamp, I modify to numeric and then the label back to time. But I did this in the module original code .

My code is at https://github.com/bzimons/MCspeedrun , check it out the code _make_chart.py at bar_chart_race2 folder around line 376 to 384

Maybe you can add the positive number to your data and then subtract it in this part of the original module.

Hope it can help you make the modifications to get what you wanted :)