Skip to content

help filtering points from a scatterplot

4 messages · Dallas, Vining, Kelly

#
Dear useRs,
I'm having trouble with what is likely a very simple issue with a simple graph. I have data in the format pasted below - total from which this is a subset is > 3 million rows. I'm plotting "Window" on the x axis, and either of the other two columns on the y axis. In both the second and third columns, the values are in a range from 0 to 1. I want to be able to plot *only* the points for which the y value is below a certain cutoff - say, 0.1. But when I try to do this, I end up filtering out the whole row from the data set, and I want to retain the "Window" and just not have any y-value plotted as a point in that window. I'm attaching what I've been able to plot with ggplot - sorry for the file size. I'd like to be able to plot just the points shaded in blue, for example. 

Any help is appreciated.

Kelly V.

Code for the ggplot:
+ geom_point() +
+ scale_colour_gradientn(colours=rainbow(4))


Example Data:
Window     Explant ExplantInv
1  168030 0.036590781  0.9634092
2  168031 1.000000000  0.0000000
3  168032 1.000000000  0.0000000
4  168033 1.000000000  0.0000000
5  168034 1.000000000  0.0000000
6  168035 1.000000000  0.0000000
7  168036 1.000000000  0.0000000
8  168037 1.000000000  0.0000000
9  168038 0.011638925  0.9883611
10 168039 0.416783189  0.5832168
11 168040 1.000000000  0.0000000
12 168041 0.031325696  0.9686743
13 168042 0.118549313  0.8814507
14 168043 1.000000000  0.0000000
15 168044 1.000000000  0.0000000
16 168045 1.000000000  0.0000000
17 168046 1.000000000  0.0000000
18 168047 1.000000000  0.0000000
19 168048 1.000000000  0.0000000
20 168049 1.000000000  0.0000000
21 168050 1.000000000  0.0000000
22 168051 0.312449302  0.6875507
23 168052 1.000000000  0.0000000
24 168053 1.000000000  0.0000000
25 168054 1.000000000  0.0000000
26 168055 1.000000000  0.0000000
27 168056 1.000000000  0.0000000
28 168057 1.000000000  0.0000000
29 168058 1.000000000  0.0000000
30 168059 0.836044243  0.1639558
31 168060 1.000000000  0.0000000
32 168061 1.000000000  0.0000000
33 168062 0.001734177  0.9982658
34 168063 1.000000000  0.0000000
35 168064 1.000000000  0.0000000
36 168065 1.000000000  0.0000000
37 168066 0.001596044  0.9984040
38 168067 1.000000000  0.0000000
39 168068 1.000000000  0.0000000
40 168069 1.000000000  0.0000000
41 168070 1.000000000  0.0000000
42 168071 1.000000000  0.0000000
43 168072 1.000000000  0.0000000
#
I believe this is what you want to do, though it may need tweaking.

#Make up some data
#Make a matrix
#Subset the matrix based upon values of interest
#Plot values
Hope this helps. 



--
View this message in context: http://r.789695.n4.nabble.com/help-filtering-points-from-a-scatterplot-tp4415833p4417247.html
Sent from the R help mailing list archive at Nabble.com.
#
Thanks for the suggestion, Tad, but that's not quite it. That is still taking a subset of the whole data set, so I am losing some of the x("Window") values. I need to be able to retain all of the x values (column a in your example), but not plot any points above. Maybe I need to construct a blank x-y plot first with the needed range of x values, then use "points" to plot my data values? Not sure how exactly to do that...

--Kelly V.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Dallas
Sent: Friday, February 24, 2012 5:58 AM
To: r-help at r-project.org
Subject: Re: [R] help filtering points from a scatterplot

I believe this is what you want to do, though it may need tweaking.

#Make up some data
#Make a matrix
#Subset the matrix based upon values of interest
#Plot values
Hope this helps. 



--
View this message in context: http://r.789695.n4.nabble.com/help-filtering-points-from-a-scatterplot-tp4415833p4417247.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Okay. I think I understand now. You would just like nothing to be plotted for
the points below a certain threshold but there will still be that space
indexing where the point would've gone. I hope I have this right. 

So what you could do to fix that is to make a new matrix (still including
all the data) and then make values above a certain threshold NA. 


#Make up some data
#Make a matrix
#Make values above a threshold = NA
#Plot values
Okay. You just solved it. I'll still post this if you would like to use it. 

Tad


--
View this message in context: http://r.789695.n4.nabble.com/help-filtering-points-from-a-scatterplot-tp4415833p4418169.html
Sent from the R help mailing list archive at Nabble.com.