|
From: Alexa V. <ale...@gm...> - 2012-02-11 17:41:05
|
Hi All, I'm just getting started with matplotlib. I'm trying to make a contour plot using contourf and have the different paths colored and semi transparent but the alpha keyword doesn't seem to do anything. I googled around and found that other people have had this same problem but I didn't find a solution. Here's what I'm doing - contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig], alpha= 0.20, colors='magenta') contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig], alpha= 0.20, colors='blue') contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig], alpha= 0.20, colors='green') To plot them all together. For reference my machine is running Mac OS X 10.6.8 and my version of matplotlib is 1.2.x Thanks! |
|
From: Eric F. <ef...@ha...> - 2012-02-11 18:23:28
|
On 02/11/2012 07:40 AM, Alexa Villaume wrote:
> Hi All,
>
> I'm just getting started with matplotlib. I'm trying to make a contour
> plot using contourf and have the different paths colored and semi
> transparent but the alpha keyword doesn't seem to do anything. I googled
> around and found that other people have had this same problem but I
> didn't find a solution. Here's what I'm doing -
>
> contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig],
> alpha=0.20, colors='magenta')
>
> contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig],
> alpha=0.20, colors='blue')
>
> contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig],
> alpha=0.20, colors='green')
>
>
> To plot them all together.
>
> For reference my machine is running Mac OS X 10.6.8 and my version of
> matplotlib is 1.2.x
>
> Thanks!
Please provide a minimal but complete script that illustrates the
problem; describe what it is in the output that does not match your
expectations. e.g.,
import numpy as np
import matplotlib.pyplot as plt
z = np.arange(20).reshape(4,5)
plt.contourf(z, levels=[2,3], alpha=0.2, colors='magenta')
plt.savefig("testcontourf_alpha.png")
which produces a pale magenta stripe, as expected, with mpl from github
master.
Eric
>
>
>
> ------------------------------------------------------------------------------
> Virtualization& Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Eric F. <ef...@ha...> - 2012-02-11 20:49:13
|
On 02/11/2012 10:30 AM, Alexa Villaume wrote:
> Thanks for replying Eric.
(You're welcome. But please keep replies on the list when they are
potentially useful to others, as yours is.)
>
> Here is my minimal script -
>
> import matplotlib
>
> frompylab import*
>
> import numpy as np
>
> importos
>
>
> metals=np.arange(-3.0, 1.1, 0.1)
>
> U=np.arange(-6.0, 0.25, 0.25)
>
> o3=np.zeros([25,41])
>
>
> plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig], alpha=0.20,
> colors='blue')
>
> plt.savefig("CoutourPlot.ps")
The Postscript language does not support transparency, so transparency
is lost when you use the mpl postscript backend. The way to work around
this, if you really need to end up with a postscript file, is to save
the file as pdf, and then use a converter program to render that as
postscript. (It might be a "print-to-file" or "save-as" option on your
pdf display program, for example. I don't know what is typically
available on a Mac, but Macs have long been pdf-friendly. In general,
the need for ps files has been diminishing. I almost never generate
them any more.)
Eric
>
>
> It plots fine except except there is no transparency in colors of the
> contour, it's like alpha is always set to 1.0
>
> On Sat, Feb 11, 2012 at 8:23 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 02/11/2012 07:40 AM, Alexa Villaume wrote:
> > Hi All,
> >
> > I'm just getting started with matplotlib. I'm trying to make a
> contour
> > plot using contourf and have the different paths colored and semi
> > transparent but the alpha keyword doesn't seem to do anything. I
> googled
> > around and found that other people have had this same problem but I
> > didn't find a solution. Here's what I'm doing -
> >
> > contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig],
> > alpha=0.20, colors='magenta')
> >
> > contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig],
> > alpha=0.20, colors='blue')
> >
> > contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig],
> > alpha=0.20, colors='green')
> >
> >
> > To plot them all together.
> >
> > For reference my machine is running Mac OS X 10.6.8 and my version of
> > matplotlib is 1.2.x
> >
> > Thanks!
>
> Please provide a minimal but complete script that illustrates the
> problem; describe what it is in the output that does not match your
> expectations. e.g.,
>
> import numpy as np
> import matplotlib.pyplot as plt
> z = np.arange(20).reshape(4,5)
> plt.contourf(z, levels=[2,3], alpha=0.2, colors='magenta')
> plt.savefig("testcontourf_alpha.png")
>
> which produces a pale magenta stripe, as expected, with mpl from github
> master.
>
> Eric
|
|
From: Alexa V. <ale...@gm...> - 2012-02-12 08:53:21
|
(Sorry about not replying to list before. I usually have to be pretty
vigilant about not clicking "Reply-All")
I made my figure a pdf and the transparency works fine. So thanks! Just
another quick question is it the Postscript language itself that doesn't
support transparency or the way mpl handles postscript files?
On Sat, Feb 11, 2012 at 10:48 AM, Eric Firing <ef...@ha...> wrote:
> On 02/11/2012 10:30 AM, Alexa Villaume wrote:
>
>> Thanks for replying Eric.
>>
>
> (You're welcome. But please keep replies on the list when they are
> potentially useful to others, as yours is.)
>
>
>
>> Here is my minimal script -
>>
>> import matplotlib
>>
>> frompylab import*
>>
>> import numpy as np
>>
>> importos
>>
>>
>> metals=np.arange(-3.0, 1.1, 0.1)
>>
>> U=np.arange(-6.0, 0.25, 0.25)
>>
>> o3=np.zeros([25,41])
>>
>>
>> plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig], alpha=0.20,
>> colors='blue')
>>
>> plt.savefig("CoutourPlot.ps")
>>
>
> The Postscript language does not support transparency, so transparency is
> lost when you use the mpl postscript backend. The way to work around this,
> if you really need to end up with a postscript file, is to save the file as
> pdf, and then use a converter program to render that as postscript. (It
> might be a "print-to-file" or "save-as" option on your pdf display program,
> for example. I don't know what is typically available on a Mac, but Macs
> have long been pdf-friendly. In general, the need for ps files has been
> diminishing. I almost never generate them any more.)
>
> Eric
>
>
>>
>> It plots fine except except there is no transparency in colors of the
>> contour, it's like alpha is always set to 1.0
>>
>> On Sat, Feb 11, 2012 at 8:23 AM, Eric Firing <ef...@ha...
>> <mailto:ef...@ha...>> wrote:
>>
>> On 02/11/2012 07:40 AM, Alexa Villaume wrote:
>> > Hi All,
>> >
>> > I'm just getting started with matplotlib. I'm trying to make a
>> contour
>> > plot using contourf and have the different paths colored and semi
>> > transparent but the alpha keyword doesn't seem to do anything. I
>> googled
>> > around and found that other people have had this same problem but I
>> > didn't find a solution. Here's what I'm doing -
>> >
>> > contourf(metals, U, o3, levels=[o3col-nsig*o3sig, o3col+nsig*o3sig],
>> > alpha=0.20, colors='magenta')
>> >
>> > contourf(metals, U, o2, levels=[o2col-nsig*o2sig, o2col+nsig*o2sig],
>> > alpha=0.20, colors='blue')
>> >
>> > contourf(metals, U, c3, levels=[c3col-nsig*c3sig, c3col+nsig*c3sig],
>> > alpha=0.20, colors='green')
>> >
>> >
>> > To plot them all together.
>> >
>> > For reference my machine is running Mac OS X 10.6.8 and my version
>> of
>> > matplotlib is 1.2.x
>> >
>> > Thanks!
>>
>> Please provide a minimal but complete script that illustrates the
>> problem; describe what it is in the output that does not match your
>> expectations. e.g.,
>>
>> import numpy as np
>> import matplotlib.pyplot as plt
>> z = np.arange(20).reshape(4,5)
>> plt.contourf(z, levels=[2,3], alpha=0.2, colors='magenta')
>> plt.savefig("testcontourf_**alpha.png")
>>
>> which produces a pale magenta stripe, as expected, with mpl from github
>> master.
>>
>> Eric
>>
>
|
|
From: Eric F. <ef...@ha...> - 2012-02-12 17:47:08
|
On 02/11/2012 10:53 PM, Alexa Villaume wrote:
> (Sorry about not replying to list before. I usually have to be pretty
> vigilant about not clicking "Reply-All")
>
> I made my figure a pdf and the transparency works fine. So thanks! Just
> another quick question is it the Postscript language itself that doesn't
> support transparency or the way mpl handles postscript files?
It is the language itself.
Eric
>
> On Sat, Feb 11, 2012 at 10:48 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 02/11/2012 10:30 AM, Alexa Villaume wrote:
>
> Thanks for replying Eric.
>
>
> (You're welcome. But please keep replies on the list when they are
> potentially useful to others, as yours is.)
>
>
>
> Here is my minimal script -
>
> import matplotlib
>
> frompylab import*
>
> import numpy as np
>
> importos
>
>
> metals=np.arange(-3.0, 1.1, 0.1)
>
> U=np.arange(-6.0, 0.25, 0.25)
>
> o3=np.zeros([25,41])
>
>
> plt.contourf(metals, U, o3, levels=[o3col-nsig*o3sig], alpha=0.20,
> colors='blue')
>
> plt.savefig("CoutourPlot.ps")
>
>
> The Postscript language does not support transparency, so
> transparency is lost when you use the mpl postscript backend. The
> way to work around this, if you really need to end up with a
> postscript file, is to save the file as pdf, and then use a
> converter program to render that as postscript. (It might be a
> "print-to-file" or "save-as" option on your pdf display program, for
> example. I don't know what is typically available on a Mac, but
> Macs have long been pdf-friendly. In general, the need for ps files
> has been diminishing. I almost never generate them any more.)
>
> Eric
>
>
>
> It plots fine except except there is no transparency in colors
> of the
> contour, it's like alpha is always set to 1.0
>
> On Sat, Feb 11, 2012 at 8:23 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>
> <mailto:ef...@ha... <mailto:ef...@ha...>>> wrote:
>
> On 02/11/2012 07:40 AM, Alexa Villaume wrote:
> > Hi All,
> >
> > I'm just getting started with matplotlib. I'm trying to make a
> contour
> > plot using contourf and have the different paths colored and semi
> > transparent but the alpha keyword doesn't seem to do anything. I
> googled
> > around and found that other people have had this same problem
> but I
> > didn't find a solution. Here's what I'm doing -
> >
> > contourf(metals, U, o3, levels=[o3col-nsig*o3sig,
> o3col+nsig*o3sig],
> > alpha=0.20, colors='magenta')
> >
> > contourf(metals, U, o2, levels=[o2col-nsig*o2sig,
> o2col+nsig*o2sig],
> > alpha=0.20, colors='blue')
> >
> > contourf(metals, U, c3, levels=[c3col-nsig*c3sig,
> c3col+nsig*c3sig],
> > alpha=0.20, colors='green')
> >
> >
> > To plot them all together.
> >
> > For reference my machine is running Mac OS X 10.6.8 and my
> version of
> > matplotlib is 1.2.x
> >
> > Thanks!
>
> Please provide a minimal but complete script that
> illustrates the
> problem; describe what it is in the output that does not
> match your
> expectations. e.g.,
>
> import numpy as np
> import matplotlib.pyplot as plt
> z = np.arange(20).reshape(4,5)
> plt.contourf(z, levels=[2,3], alpha=0.2, colors='magenta')
> plt.savefig("testcontourf___alpha.png")
>
> which produces a pale magenta stripe, as expected, with mpl
> from github
> master.
>
> Eric
>
>
|