I've been giving a shot to auditorium for presentations and like it so far, but there are a few things that it would be great to make configurable. I'd love to submit a PR, but wanted to check on preferred approach to implementing feature.
The issue I'm trying to solve is that when using plotnine, many figures (especially legends) get cropped out. I traced this down to that pyplot https://github.com/apiad/auditorium/blob/master/auditorium/show.py#L340 calls plt.tight_layout(). On the other hand, plotnine does not call that, but makes a call like plt.savefig(filename, bbox_inches='tight' (https://plotnine.readthedocs.io/en/stable/_modules/plotnine/ggplot.html#ggplot.save).
I'd propose something like:
- Add a parameter to
pyplot like savefig_args and change the savefig call to plt.savefig(buffer, format=fmt, **savefig_args)
- Add a parameter
tight_layout=True (or False) so only call plt.tight_layout() if it is True
Combined, this would make it so that I can display plotnine plots as they're intended to look, without monkey patching the pyplot call. Another possibility is in addition to (1)/(2), add argument on Show where the defaults can be set, although a similar thing could be accomplished in user code like
def myplot(ctx, plt):
ctx.pyplot(plt, savefig_args={}, tight_layout=False)
def myslide(ctx):
myplot(ctx, someplot)
I've been giving a shot to auditorium for presentations and like it so far, but there are a few things that it would be great to make configurable. I'd love to submit a PR, but wanted to check on preferred approach to implementing feature.
The issue I'm trying to solve is that when using plotnine, many figures (especially legends) get cropped out. I traced this down to that
pyplothttps://github.com/apiad/auditorium/blob/master/auditorium/show.py#L340 callsplt.tight_layout(). On the other hand,plotninedoes not call that, but makes a call likeplt.savefig(filename, bbox_inches='tight'(https://plotnine.readthedocs.io/en/stable/_modules/plotnine/ggplot.html#ggplot.save).I'd propose something like:
pyplotlikesavefig_argsand change thesavefigcall toplt.savefig(buffer, format=fmt, **savefig_args)tight_layout=True(orFalse) so only callplt.tight_layout()if it isTrueCombined, this would make it so that I can display plotnine plots as they're intended to look, without monkey patching the
pyplotcall. Another possibility is in addition to (1)/(2), add argument onShowwhere the defaults can be set, although a similar thing could be accomplished in user code like