bar_chart_race icon indicating copy to clipboard operation
bar_chart_race copied to clipboard

Outside axis labels are slightly blury and look different from labels within the axis.

Open slyuber opened this issue 4 years ago • 2 comments

Hey Guys!

First off, thank you so much for all the work you've put in to this great tool! Issue is basically described in the subject. The axis labels of all my plots are coming out a bit blurry.

Nothing crazy going on code wise, but here is the setup causing the issue:

  • Anaconda3
  • Jupyter Labs running on Windows

bcr.bar_chart_race(df=plot_df, fixed_max= True, n_bars=8, period_length=1000, dpi = 300, period_fmt='Year: {x:.0f}', title = "Popularity of Bachelor Degrees in the US from 1970 to 2017", tick_label_size=9, perpendicular_bar_func='mean', cmap='set3', filter_column_colors=True, )

test21

slyuber avatar Jan 18 '21 17:01 slyuber

I'm having the same issue on Mac OS Catalina - @slyuber did you come up with a way to fix that?

mcaay avatar Feb 27 '21 08:02 mcaay

I was able to fix this by setting the figure background color. You have to create a figure yourself and pass that to the bar_chart_race function. This is the code:

# Set up a figure looking like bar_chart_race's default.
fig, ax = plt.subplots(figsize=(4, 2.5), dpi=144)
ax.set_facecolor('.8')
ax.tick_params(labelsize=8, length=0)
ax.grid(True, axis='x', color='white')
ax.set_axisbelow(True)
[spine.set_visible(False) for spine in ax.spines.values()]

# Setting background to a solid color fixes the problem.
fig.patch.set_facecolor('white')

# Do the thing.
bcr.bar_chart_race(df=plot_df, fig=fig)

My guess is that the font can't be properly antialiased on transparent background, which would explain why it looks fine inside the plot.

chairuser avatar Mar 16 '21 15:03 chairuser