From: Francesco M. <fra...@gm...> - 2012-07-17 15:10:16
Attachments:
show_mimic_alpha.pdf
show_mimic_alpha_red_background.pdf
|
Dear matplotlibers, after spending some more time about my problem on how to emulate transparency to create nice eps figures with shaded areas, I found this web page: http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1 So I decided to implement the algorithm and it seems that the approach works (see attached pdf). Of course if there are many layers of transparent colors, it would be very hard to get the exact colors, but so far it's the best approach that I've found. The code can be downloaded from here: https://github.com/montefra/mimic_alpha/downloads Cheers, Francesco |
From: Jonathan S. <js...@cf...> - 2012-07-17 20:30:26
|
Francesco, While I like your solution, there is an alternative that is simpler and works for me. That is 1) save matplotlib plot as a png, 2) convert to eps using either ImageMagick or GraphicsMagick. You do end up with relatively large files, but they look identical to the original plots. Regards, Jon > Dear matplotlibers, > > after spending some more time about my problem on how to > emulate > transparency to create nice eps figures with shaded areas, > I found this web page: > http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1 > > So I decided to implement the algorithm and it seems that the > approach > works (see attached pdf). > Of course if there are many layers of transparent colors, it > would be > very hard to get the exact colors, but so far it's the best > approach > that I've found. > > The code can be downloaded from here: > https://github.com/montefra/mimic_alpha/downloads > > Cheers, > Francesco -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA js...@cf... 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ |
From: Benjamin R. <ben...@ou...> - 2012-07-17 20:35:05
|
On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin <js...@cf...>wrote: > Francesco, > > While I like your solution, there is an alternative that is simpler and > works for me. That is 1) save matplotlib plot as a png, 2) convert to > eps using either ImageMagick or GraphicsMagick. You do end up with > relatively large files, but they look identical to the original plots. > > Regards, > Jon > No, it is not the same thing. Text in a vector-based format such as eps is scalable. ImageMagick and GraphicsMagick are inherently raster-based, and before that, PNGs are raster-based. Therefore, the text is not scaled and anti-aliased according to the display size. I will be looking over the proposed solution this evening. Cheers! Ben Root |
From: Jonathan S. <js...@cf...> - 2012-07-18 14:34:31
|
Ben, Yes, you're right, but I doubt any solution that involves mimicking an alpha channel will work for one case that I've been using. That is, making the legend box partially transparent. I use that to allow the box to fit in the plot without blocking the data and without the need to make the upper y limit too large. I don't notice any problems with blockiness in the text or lines in the raster image. I'll find out soon if the editors of the Astrophysical Journal are okay with the figures. Jon On Tue, 2012-07-17 at 15:34 -0500, Benjamin Root wrote: > > > On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin > <js...@cf...> wrote: > Francesco, > > While I like your solution, there is an alternative that is > simpler and > works for me. That is 1) save matplotlib plot as a png, 2) > convert to > eps using either ImageMagick or GraphicsMagick. You do end up > with > relatively large files, but they look identical to the > original plots. > > Regards, > Jon > > No, it is not the same thing. Text in a vector-based format such as > eps is scalable. ImageMagick and GraphicsMagick are inherently > raster-based, and before that, PNGs are raster-based. Therefore, the > text is not scaled and anti-aliased according to the display size. > > I will be looking over the proposed solution this evening. > > Cheers! > Ben Root > > -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA js...@cf... 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ |
From: Francesco M. <fra...@gm...> - 2012-07-18 14:50:55
|
2012/7/18 Jonathan Slavin <js...@cf...>: > Ben, > > Yes, you're right, but I doubt any solution that involves mimicking an > alpha channel will work for one case that I've been using. That is, > making the legend box partially transparent. I use that to allow the > box to fit in the plot without blocking the data and without the need to > make the upper y limit too large. My solution would probably work if you could, pixel by pixel (or patch by patch), mimic alpha in each layer using as background the resulting color of the previous layer. Do anyone know if it is possible to implement something like this in matplotlib when saving a eps or in a backend? > > I don't notice any problems with blockiness in the text or lines in the > raster image. I'll find out soon if the editors of the Astrophysical > Journal are okay with the figures. I guess that you produce the figures roughly of the right size (about 8 or 16 cms wide for single or double column figures) and then convert. So probably you see that the figure is a raster if you zoom in. Fra > > Jon > > On Tue, 2012-07-17 at 15:34 -0500, Benjamin Root wrote: >> >> >> On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin >> <js...@cf...> wrote: >> Francesco, >> >> While I like your solution, there is an alternative that is >> simpler and >> works for me. That is 1) save matplotlib plot as a png, 2) >> convert to >> eps using either ImageMagick or GraphicsMagick. You do end up >> with >> relatively large files, but they look identical to the >> original plots. >> >> Regards, >> Jon >> >> No, it is not the same thing. Text in a vector-based format such as >> eps is scalable. ImageMagick and GraphicsMagick are inherently >> raster-based, and before that, PNGs are raster-based. Therefore, the >> text is not scaled and anti-aliased according to the display size. >> >> I will be looking over the proposed solution this evening. >> >> Cheers! >> Ben Root >> >> > -- > ______________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > js...@cf... 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ______________________________________________________________ > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Francesco M. <fra...@gm...> - 2012-07-19 20:45:32
|
2012/7/18 Francesco Montesano <fra...@gm...>: > 2012/7/18 Jonathan Slavin <js...@cf...>: >> Ben, >> >> Yes, you're right, but I doubt any solution that involves mimicking an >> alpha channel will work for one case that I've been using. That is, >> making the legend box partially transparent. I use that to allow the >> box to fit in the plot without blocking the data and without the need to >> make the upper y limit too large. > My solution would probably work if you could, pixel by pixel (or patch > by patch), mimic alpha in each layer using as background the resulting > color of the previous layer. > > Do anyone know if it is possible to implement something like this in > matplotlib when saving a eps or in a backend? > >> >> I don't notice any problems with blockiness in the text or lines in the >> raster image. I'll find out soon if the editors of the Astrophysical >> Journal are okay with the figures. > I guess that you produce the figures roughly of the right size (about > 8 or 16 cms wide for single or double column figures) and then > convert. So probably you see that the figure is a raster if you zoom > in. > > Fra > >> >> Jon >> >> On Tue, 2012-07-17 at 15:34 -0500, Benjamin Root wrote: >>> >>> >>> On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin >>> <js...@cf...> wrote: >>> Francesco, >>> >>> While I like your solution, there is an alternative that is >>> simpler and >>> works for me. That is 1) save matplotlib plot as a png, 2) >>> convert to >>> eps using either ImageMagick or GraphicsMagick. You do end up >>> with >>> relatively large files, but they look identical to the >>> original plots. >>> >>> Regards, >>> Jon >>> >>> No, it is not the same thing. Text in a vector-based format such as >>> eps is scalable. ImageMagick and GraphicsMagick are inherently >>> raster-based, and before that, PNGs are raster-based. Therefore, the >>> text is not scaled and anti-aliased according to the display size. >>> >>> I will be looking over the proposed solution this evening. >>> >>> Cheers! >>> Ben Root >>> >>> Dear matplotlibers, I've uploaded a new version which accepts also lists/tuple/numpy arrays of colors and/or alphas and returns a list of RGB colors. https://github.com/montefra/mimic_alpha https://github.com/montefra/mimic_alpha/downloads Cheers, Francesco |