SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: marcusantonius <mar...@st...> - 2008年10月27日 22:40:13
I'm sorry for this newbie question. I have a data file consisting of 3
columns, and want to plot the first versus the second column, but only if
the parameter in the third column lies in a certain range. Does somebody
have an idea how to do that?
-- 
View this message in context: http://www.nabble.com/How-to-plot-only-points-which-lie-in-a-certain-range-tp20178863p20178863.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: <bre...@un...> - 2008年10月27日 23:21:02
You need to use the numpy 'where' functionality
import numpy as np
x, y, z = np.loadtxt("fileName.dat", unpack=True) # or similar
# x, y and z are now numpy arrays and have built in functionality as 
follows:
s = (z < 10.0) & (z**2 > 0.5) # or some other constraint. Produces an 
array 's' of boolean values
plot(x[s], y[s]) # will plot only those x,y pairs for which s is True
marcusantonius <mar...@st...> 
28/10/2008 09:40 AM
To
mat...@li...
cc
Subject
[Matplotlib-users] How to plot only points which lie in a certain range
I'm sorry for this newbie question. I have a data file consisting of 3
columns, and want to plot the first versus the second column, but only if
the parameter in the third column lies in a certain range. Does somebody
have an idea how to do that?
-- 
View this message in context: 
http://www.nabble.com/How-to-plot-only-points-which-lie-in-a-certain-range-tp20178863p20178863.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's 
challenge
Build the coolest Linux based applications with Moblin SDK & win great 
prizes
Grand prize is a trip for two to an Open Source event anywhere in the 
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
UNITED GROUP
This email message is the property of United Group. The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, you may not disclose, copy or distribute this email, nor take or omit to take any action in reliance on it. United Group accepts no liability for any damage caused by this email or any attachments due to viruses, interference, interception, corruption or unauthorised access.
If you have received this email in error, please notify United Group immediately by email to the sender's email address and delete this document.
From: Pierre GM <bac...@gm...> - 2008年10月27日 22:59:43
On Monday 27 October 2008 18:40:07 marcusantonius wrote:
> I'm sorry for this newbie question. I have a data file consisting of 3
> columns, and want to plot the first versus the second column, but only if
> the parameter in the third column lies in a certain range. Does somebody
> have an idea how to do that?
Using masked arrays ?
import numpy as np
import numpy as ma
import matplotlib.pyplot as mpl
x = ma.arange(10)
y = ma.array(np.random.rand(10))
z = ma.array(np.random.rand(10))
(z_lo, z_up) = (0.1, 0.8)
x[ (z<z_lo) | (z>z_up) ] = ma.masked
mpl.plot(x,y, 'ok-')
Alternatively,
x = ma.masked_where((z<z_lo) | (z>z_up), x)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /