[matplotlib-devel] registerable backend and minor refactoring of backend-ps
Dear all, I just committed a small change that enables a user to register a custom backend that will be used with "savefig". For example, import matplotlib.backend_bases from matplotlib.backends.backend_ps import FigureCanvasPS, RendererPS class RendererPSCustom(RendererPS): def draw_path(self, gc, path, transform, rgbFace=None): print "custom draw path" RendererPS.draw_path(self, gc, path, transform, rgbFace) class FigureCanvasPSCustom(FigureCanvasPS): _renderer_class = RendererPSCustom def print_eps_custom(self, outfile, *args, **kwargs): print "Using Custome backend" return self._print_ps(outfile, 'eps', *args, **kwargs) matplotlib.backend_bases.register_backend("eps_custom", FigureCanvasPSCustom) plt.plot([1,2,3]) plt.savefig("a.eps", format="eps_custom") # this will save the file using backend_ps_cmyk The api may need some cleanups or modifications, and any suggestion will be welcomed. Also committed is a some refactoring of ps backend but the change should be quite transparent. Regards, -JJ -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] ps backend with images in cmyk
I'm experimenting with a customized ps backend that saves images in cmyk colorspace. It simply converts the rgb image to cmyk (using lcms), and nothing more (i.e., it does not embed the icc profile inside the eps file). While I don't see practical usefulness of this other than for a previewing purpose, give it a try if you're interested (the current svn matplotlib is required). Any comment of suggestion will be welcomed. http://github.com/leejjoon/mpl_ps_cmyk Regards, -JJ -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] registerable backend and minor refactoring of backend-ps
On Wed, Feb 3, 2010 at 2:01 PM, Jae-Joon Lee wrote: > Dear all, > > I just committed a small change that enables a user to register a > custom backend that will be used with "savefig". > For example, > > import matplotlib.backend_bases > from matplotlib.backends.backend_ps import FigureCanvasPS, RendererPS > > class RendererPSCustom(RendererPS): > def draw_path(self, gc, path, transform, rgbFace=None): > print "custom draw path" > RendererPS.draw_path(self, gc, path, transform, rgbFace) > > class FigureCanvasPSCustom(FigureCanvasPS): > _renderer_class = RendererPSCustom > > def print_eps_custom(self, outfile, *args, **kwargs): > print "Using Custome backend" > return self._print_ps(outfile, 'eps', *args, **kwargs) > > > matplotlib.backend_bases.register_backend("eps_custom", FigureCanvasPSCustom) > > plt.plot([1,2,3]) > plt.savefig("a.eps", format="eps_custom") # this will save the file > using backend_ps_cmyk > > > The api may need some cleanups or modifications, and any suggestion > will be welcomed. > > Also committed is a some refactoring of ps backend but the change > should be quite transparent. I like it. Out of curiosity, is there anything that this approach brings (other than simplicity) that isn't already covered by the support for: matplotlib.use('module:://') ? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] registerable backend and minor refactoring of backend-ps
Nothing much in the regards of the functionality. It only provides a way to use custom backends with "savefig", which I think is more convenient for interactive use. For example, with the ps_cmyk backend that I'm playing with, the only thing that I need to do is to import the module (ps_cmyk) and call savefig("test.eps", format="eps_cmyk") And all other (interactive) work flow is not affected by the use of the custome backend. In non-interactive mode where a user explicitly calls "matplotlib.use", there is no need to register a backend. Regards, -JJ On Wed, Feb 3, 2010 at 4:15 PM, Ryan May wrote: > On Wed, Feb 3, 2010 at 2:01 PM, Jae-Joon Lee wrote: >> Dear all, >> >> I just committed a small change that enables a user to register a >> custom backend that will be used with "savefig". >> For example, >> >> import matplotlib.backend_bases >> from matplotlib.backends.backend_ps import FigureCanvasPS, RendererPS >> >> class RendererPSCustom(RendererPS): >> def draw_path(self, gc, path, transform, rgbFace=None): >> print "custom draw path" >> RendererPS.draw_path(self, gc, path, transform, rgbFace) >> >> class FigureCanvasPSCustom(FigureCanvasPS): >> _renderer_class = RendererPSCustom >> >> def print_eps_custom(self, outfile, *args, **kwargs): >> print "Using Custome backend" >> return self._print_ps(outfile, 'eps', *args, **kwargs) >> >> >> matplotlib.backend_bases.register_backend("eps_custom", FigureCanvasPSCustom) >> >> plt.plot([1,2,3]) >> plt.savefig("a.eps", format="eps_custom") # this will save the file >> using backend_ps_cmyk >> >> >> The api may need some cleanups or modifications, and any suggestion >> will be welcomed. >> >> Also committed is a some refactoring of ps backend but the change >> should be quite transparent. > > I like it. Out of curiosity, is there anything that this approach > brings (other than simplicity) that isn't already covered by the > support for: > > matplotlib.use('module:://') > > ? > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A small improvement to plot directive
On Thu, Jan 28, 2010 at 2:51 PM, Fernando Perez wrote: > Thanks, with your and John's (off-list) approvals, it's committed. > The patch that went in had more docs than what I posted here, but the > code is identical. Oops, somehow my commit had never made it, I just noticed now I was trying to use it from another machine. Fixed now, r8110. Cheers, f -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel