Closed jrichdyer closed 3 years ago
Hey there! Nice pickup & thank you for raising this π
Here's a reproducible example where we can note that the current version doesn't show the period_summary_func text:
import pandas_alive
covid_df = pandas_alive.load_dataset()
def current_total(values):
total = values.sum()
s = f"Total : {int(total)}"
return {"x": 0.85, "y": 0.2, "s": s, "ha": "right", "size": 11}
covid_df.plot_animated(
filename="test.gif",
kind="pie",
period_summary_func=current_total,
enable_progress_bar=True,
)
It seems as if BarChartRace already had a fix for this which wasn't transferred to other chart types in that _base_chart.show_period(i)
is called after plot_bars
to ensure that the period_summary_func
isn't lost.
I've implemented this fix for all other chart types as well. π (and took the opportunity to do some refactoring as well). Find the changes at https://github.com/JackMcKew/pandas_alive/commit/1776c5a838e9e6bc4c36b0d82114c90c5ca3f929
After testing happens, I'll be sure to make a release but not sure on the timeline at this point in time.
I'll close this when it gets released on PyPI
0.2.4 is now released π
When calling
plot_animated()
and specifyingkind='pie'
, theperiod_summary_func
parameter appears to be ignored. I tried specifying my own figure and adding my own text withax.text()
but that fails to show up in the pie chart animation as well.After a little digging, it looks like that's because the text is explicitly removed in charts.py, on lines 633-644:
This can't be commented out, since it prevents wedge labels from piling up on top of each other as the wedges change. The only thing I could think of to fix it was to add the text created by
period_summary_func
back in afterward. To do that, I added the following code (which is just copied from lines 551-563 of _base_chart.py) to charts.py after line 650:This works as a quick fix for me, but it's not the most elegant solution, which is why I chose to throw it here instead of creating a PR.