mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.59k stars 1.93k forks source link

Pointplot error bars do not respect rasterized=True #3774

Closed ASLeonard closed 3 weeks ago

ASLeonard commented 3 weeks ago

Using v0.13.2, I was making a pointplot with many points. To save space on the figure, I was passing searbon.pointplot(rasterized=True,...), but the svg was still extremely large. It turns out that the rasterized keyword only gets passed to the scatter portion of the call, and the error bars were plotted as vector graphics still.

This was simple to fix by adding "rasterized" to this iteration within the plot_errorbars function, but there may be other places I didn't check that would need something similar. However, I can confirm this correctly rasterizes the errorbars.

https://github.com/mwaskom/seaborn/blob/b4e5f8d261d6d5524a00b7dd35e00a40e4855872/seaborn/categorical.py#L1235

mwaskom commented 3 weeks ago

Can you pass it to err_kws?

err_kwsdict Parameters of matplotlib.lines.Line2D, for the error bar artists.

ASLeonard commented 3 weeks ago

Passing it via seaborn.pointplot(rasterized=True,err_kws={"rasterized":True},...) does work.

Maybe that is the most flexible situation, but I can't imagine many circumstances where you would want the estimator point to be rasterized but not the error bars. I would expect rasterized to behave similarly to other "global" options like setting seaborn.pointplot(alpha=0.2,...) affecting the transparency of both estimator and errors, but given the err_kws approach this is more preference rather than an issue now.

mwaskom commented 3 weeks ago

I agree that you probably wouldn't want to control them separately but I would prefer to have these parameters behave as documented rather than pick and choose special keyword arguments that get treated differently.

Note that as a user you may find yourself preferring

ax = sns.pointplot(...)
plt.setp(ax.get_lines(), rasterized=True)