Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Warn the user to set the Agg backend #157
referenced this pull request
Oct 26, 2016
I thought of a warning because the only reason to use Agg is to avoid the pop up. The use case is none. Yes interactive backend will pop the figures on
Why not an error, i.e. is there a use case where keeping on going with a backend other than Agg is useful?
SVG would work.
I haven't tried but for an interactive backend I would expect the build to stop at the first plt.show() ...
I think that we monkey-patch matplotlib to avoid this. The real reason that we set the backend to agg is to avoid using an X server on headless servers. Unless proven that other backends don't work, I am +1 for warning rather than error.
I actually gave it a try. For now writing images in a different format than PNG is not really supported. Main immediate problem is thumbnails(we use pillow to resize them), I actually hacked it to just pass the svg as they don't really need to be resized. With PDF, web browsers can't display pdf images only as embed or opening them individual. Thus in both cases it does not look nice.
But my new question is Agg can generate PNG and SVG and EPS and PDF(And at some point we could support all those formats), why bother selecting the other non interactive backends?
Monkey-patching seem unnecessary hard. I tried loading matplotib in interactive mode. And although it works well in the Python/IPython interpreter to continue execution after plt.show() is called. It doesn't when running sphinx-build and the figures open in my display, it is not until I close all of them that the build can continue with the next example. But most important (except the seaborn example) once I close the image there are no figure objects to save, thus no figure gets saved and we have no gallery.
I thought of the warning as a better alternative than raising the error, because I have no idea of the users use cases. I already updated the PR to give the error some hours ago, going back is not a major trouble. The question I now repeat is why use other backend if Agg outputs to all other formats? Well Cairo does too, but that one is more complicated to install as a dependency. So it a user needs that one he for sure knows why.
I believe the main point of this PR and issue #153 is to tell the user that he is unintentionally loading pylab or pyplot before Sphinx-Gallery can set the backend to AGG. So that he can change his configuration.
@anntzer any comment on this?