mimic alpha (channel) v0.1

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:
        image - Convert RGBA color to RGB - Stack Overflow
        
        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
jslavin@...1081... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
______________________________________________________________

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

···

On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin <jslavin@…1081…> 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

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 > <jslavin@...1081...> 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
jslavin@...1081... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
______________________________________________________________

2012/7/18 Jonathan Slavin <jslavin@...1081...>:

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 >> <jslavin@...1081...> 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
jslavin@...1081... 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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

2012/7/18 Francesco Montesano <franz.bergesund@...287...>:

2012/7/18 Jonathan Slavin <jslavin@...1081...>:

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

        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/downloads

Cheers,
Francesco

···

On Tue, 2012-07-17 at 15:34 -0500, Benjamin Root wrote:

On Tue, Jul 17, 2012 at 3:01 PM, Jonathan Slavin >>> <jslavin@...1081...> wrote: