Re: [Matplotlib-users] cross hatching in contours?

2012-12-05 Thread spencerahill
Jae-Joon Lee wrote
> On Thu, Sep 15, 2011 at 10:33 PM, Jonathan Slavin
> <

> [email protected]

> > wrote:
>> I'm wondering if there is some way to do cross hatching as a way to fill
>> contours rather than colors (using contourf).  The only references to
>> cross hatching I see in the documentation are for patches type objects.
>> As far as I can tell, contour and contourf return objects of their own
>> type (contour.QuadContourSet) that do not have hatch as an attribute.
>>
> 
> Yes, it seems that hatching is only supported in patches.
> You may workaround this by converting contours to multiple patches.
> See the attachment.
> 
> Matplotlib-users mailing list

> [email protected]

> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> contour_to_hatched_patches.py (1K)
> ;

Hi Jae-Joon,

Your contour_to_hatched_patches.py script works excellently. Is there a way
to suppress the contour lines and filling, leaving only stippling? I have
been experimenting with it but no luck. 

I have a contourf of a 2D variable and a separate 2D array indicating
regions of statistical significance (i.e. a mask, which equals 1 in cells
where the variable is significant and equals 0 else), and I want to put
black hatching over the contourf where it is significant. I can get this to
work, but still with a black contour line surrounding the hatched region.
I'd like to remove the line, leaving just the hatching. Thanks!

Best,
Spencer




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/cross-hatching-in-contours-tp22p39945.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cross hatching in contours?

2012-12-05 Thread Phil Elson
As of matplotlib v1.2.0 you can hatch a contour set directly. There is an
example in the gallery:

http://matplotlib.org/examples/pylab_examples/contourf_hatching.html

Hope that helps,

Phil


On 5 December 2012 17:28, spencerahill  wrote:

> Jae-Joon Lee wrote
> > On Thu, Sep 15, 2011 at 10:33 PM, Jonathan Slavin
> > <
>
> > [email protected]
>
> > > wrote:
> >> I'm wondering if there is some way to do cross hatching as a way to fill
> >> contours rather than colors (using contourf).  The only references to
> >> cross hatching I see in the documentation are for patches type objects.
> >> As far as I can tell, contour and contourf return objects of their own
> >> type (contour.QuadContourSet) that do not have hatch as an attribute.
> >>
> >
> > Yes, it seems that hatching is only supported in patches.
> > You may workaround this by converting contours to multiple patches.
> > See the attachment.
> >
> > Matplotlib-users mailing list
>
> > [email protected]
>
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
> > contour_to_hatched_patches.py (1K)
> > <
> http://matplotlib.1069221.n5.nabble.com/attachment/23/0/contour_to_hatched_patches.py>
> ;
>
> Hi Jae-Joon,
>
> Your contour_to_hatched_patches.py script works excellently. Is there a way
> to suppress the contour lines and filling, leaving only stippling? I have
> been experimenting with it but no luck.
>
> I have a contourf of a 2D variable and a separate 2D array indicating
> regions of statistical significance (i.e. a mask, which equals 1 in cells
> where the variable is significant and equals 0 else), and I want to put
> black hatching over the contourf where it is significant. I can get this to
> work, but still with a black contour line surrounding the hatched region.
> I'd like to remove the line, leaving just the hatching. Thanks!
>
> Best,
> Spencer
>
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/cross-hatching-in-contours-tp22p39945.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> --
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Varying alpha in ListedColormap not working

2012-12-05 Thread Oliver King
Hi,

I've been trying to plot a line with varying alpha (but constant color). After 
much googling I have come up with the following code segment, which by all 
indications should work. It works when I vary an individual RGB element, but 
not when I vary alpha.

#
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.colors import ListedColormap, BoundaryNorm

# the line to plot
x = np.linspace(0,1,101)
y = x*0.5-0.25
scaling = np.exp(-(x-0.5)**2/0.5**2) # scale the transparency of the line 
according to this

# Create a colormap which has a constant color, but varies the transparency.
N = 50 # this many different transparency levels
alpha_boundaries = np.linspace(np.min(scaling),np.max(scaling),N+1)
# The lowest values are transparent, the highest ones are opaque
cmap = ListedColormap([(0.0,0.0,0.0,a) for a in np.linspace(0,1,N)])
norm = BoundaryNorm(alpha_boundaries, cmap.N)

# Create a set of line segments so that we can color them individually
# This creates the points as a N x 1 x 2 array so that we can stack points
# together easily to get the segments. The segments array for line collection
# needs to be numlines x points per line x 2 (x and y)
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)

# Create the line collection object, setting the colormapping parameters.
# Have to set the actual values used for colormapping separately.
lc = LineCollection(segments, cmap=cmap, norm=norm)
lc.set_array(scaling)

ax = plt.subplot(111)
ax.add_collection(lc)
plt.xlim(x.min(), x.max())
plt.ylim(y.min(), y.max())
plt.show()
#

What appears to be happening is that the alpha values in the cmap I use when I 
create the ListedColormap object are being ignored by the add_collection 
function. I see that this bug (or something quite like it) was reported in late 
2008:
http://matplotlib.1069221.n5.nabble.com/create-ListedColormap-with-different-alpha-values-tt18693.html#a18697

Did the patch from late 2008 not make it into the code, or has this bug 
resurfaced? Does anyone know of a workaround for this issue?

Cheers,
Oliver


--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Varying alpha in ListedColormap not working

2012-12-05 Thread Paul Ivanov
On Wed, Dec 5, 2012 at 2:36 PM, Oliver King  wrote:
> What appears to be happening is that the alpha values in the cmap I use when 
> I create the ListedColormap object are being ignored by the add_collection 
> function. I see that this bug (or something quite like it) was reported in 
> late 2008:
> http://matplotlib.1069221.n5.nabble.com/create-ListedColormap-with-different-alpha-values-tt18693.html#a18697
>
> Did the patch from late 2008 not make it into the code, or has this bug 
> resurfaced? Does anyone know of a workaround for this issue?

It's all a blur now, but I don't think that patch made it in because
colormaps were inherently RGB not RGBA.

Something similar to that patch was merged in a year ago:
https://github.com/matplotlib/matplotlib/pull/660 and attached is the
result of running your code on my machine.

What is your matplotlib.__version__ ? I think that code only made it's
way into v1.2.0 (the latest stable), and was did not make it into
v1.1.1 (or anything before it)

--
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
<>--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Varying alpha in ListedColormap not working

2012-12-05 Thread Oliver King

> What is your matplotlib.__version__ ? I think that code only made it's
> way into v1.2.0 (the latest stable), and was did not make it into
> v1.1.1 (or anything before it)

I'm running 1.1.0 - I'll upgrade it now. Thanks for the help!

Oliver

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plotting time series of bits

2012-12-05 Thread Dale Lukas Peterson
I have a time series of 32-bit unsigned integers in the form of a
numpy array with dtype=numpy.uint32.  The bits of each integer in
array correspond to various boolean states collected during an
experiment.  I would like to make a plot this data in the following
way:
1)  time on the horizontal axis (I have a time array of the same
length as my integer array)
2)  bit position N on the vertical axis (0-1 corresponds to bit 0, 1-2
corresponds to bit 1, etc.)
3)  a solid filled rectangle from (t1, N) to (t1+dt, N+1) whenever the
bit is high.

I been able to use the bitwise_and() and right_shift() on the data to
get individual arrays which are populated with only 0's and1's.

What I'm not clear on is now how to get the solid filled rectangle for
areas where the bit is high and nothing when the bit is low.

Is there already this functionality somewhere in matplotlib?  I looked
in the gallery and couldn't find anything quite like what I'm looking
for, though I may have simply missed it.  If there isn't, I'm sure
there is a way to do it, does anybody have any recommendations as to
the path of least resistance?

Thanks,
Luke


-- 
“People call me a perfectionist, but I'm not. I'm a rightist. I do
something until it's right, and then I move on to the next thing.”
― James Cameron

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users