[R] Fwd: Segment out of the Graph

heverkuhn claudio.zanettini at gmail.com
Fri Aug 26 17:31:11 CEST 2011


No attachment. No code.

I apology for that. I provided below the code and the vectors,


Whatever that mean. Perhaps it means "below"? 

Yes, below, I mean out of the axis...

And I think, that as you suggested, the xpd is what I was looking for.
I need something like this 
http://www.springerimages.com/Images/Biomedicine/1-10.1385_0-89603-217-5_315-2
http://www.springerimages.com/Images/Biomedicine/1-10.1385_0-89603-217-5_315-2 
but with the vertical bars  below but with just the axis of the cumulative
responses.

Thanks guys for your time and your patience. 
Claudio

here it is the code:

plot(	activeT,activeR, pch="", type="s",
	ylim=c(-20, tail(activeR,1)),
	xlim=c(0, breakpT),
	main=c("Subj", DATA[7]),
	ylab="Cumulative Responses",
	xlab="Time (sec)",
	font.lab=2
	)
segments(reinfT$activeT, reinfR$activeR, reinfT$activeT-150,
reinfR$activeR+3, lwd=2)
points(inactT, inactR, pch="|")
segments( 0, -10, max(activeT), -10)
segments(breakpT+50,breakpR-2,breakpT-50,breakpR+2, lwd=4)

and here the vectors:

activeT
 [1]     2.6    34.1    37.6    45.9    46.6    53.2    93.5   116.3   172.1
[10]   616.7   651.3   711.4   722.5   725.4   772.8   796.4   863.0   880.3
[19]   918.6   945.3  1013.2  1066.9  1132.6  1148.6  1150.8  1171.1  1172.6
[28]  1345.0  1346.5  1596.5  1597.9  1632.4  1682.7  1695.9  1780.9  1904.8
[37]  2267.3  2326.8  3259.6  3314.8  4671.7 10671.7

activeR
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 41

breakpT
[1] 10671.7

 breakpR
[1] 41

> reinfT
   activeT
5     46.6
12   711.4
22  1066.9
36  1904.8

> reinfR
   activeR
5        5
12      12
22      22
36      36
*

> inactT
 [1]   31.6   65.6  637.8  809.8  809.9 1075.5 1144.0 1546.3 2247.4 2260.0
[11] 2793.6 2794.4 3075.7 3250.3 3250.6 3252.2 3308.2 5143.6

>inactR
 [1] "-10" "-10" "-10" "-10" "-10" "-10" "-10" "-10" "-10" "-10" "-10" "-10"
[13] "-10" "-10" "-10" "-10" "-10" "-10"

David Winsemius wrote:
> 
> On Aug 25, 2011, at 2:06 PM, Claudio Zanettini wrote:
> 
>> ---------- Forwarded message ----------
>> From: Claudio Zanettini <claudio.zanettini at gmail.com>
>> Date: 2011/8/25
>> Subject: Re: [R] Segment out of the Graph
>> To: David Winsemius <dwinsemius at comcast.net>
>>
>>
>> Thanks David and Michael,
>> In attachment there is one of the graph.
> 
> No attachment. No code.
> 
>>
>> the line below the graph is not related to the y label.
>> I draw it at y= -10 just becouse it was the only way I know for draw  
>> a line
>> parallel
>> to the x axis.
>> But it shoud be "out" of the xy axis.
> 
> Whatever that mean. Perhaps it means "below"?
>>
>> It rappresents another variable related to the one shown in the  
>> graph...
> 
> No graph.
> 
>>
>> Sorry for not being very clear :)
> 
> Please read the Posting Guide. You probably want the segments function  
> with xpd=NA or xpd =TRUE
> 
>  > plot(1:2,c(1, 500), ylim=c(0,1000), xlim=c(0,3))
>  > segments(0,-10, 3,-10, xpd=TRUE, col="red")
> 
> 
> ?par
> ?segments
> 
> 
>>
>> Claudio
>>
>>
>>
>> 2011/8/25 David Winsemius <dwinsemius at comcast.net>
>>
>>>
>>> On Aug 25, 2011, at 1:30 PM, Claudio Zanettini wrote:
>>>
>>> I tried setting ylim=(0, 1000)
>>>>> but the segment that I have draw is at y=-10
>>>>> so if I set the y origin to 0 I don t have the segment,
>>>>> if a l leave it at -10 I have the segment but the axis start from  
>>>>> -10.
>>>>>
>>>>> I would like to have both.
>>>>> So to have a graph with ylim=( 0, 1000)
>>>>> and under it a segment parallel to the x axis at  -10.
>>>>>
>>>>
>>> If you really want that then you will need to look at the xpd  
>>> parameter for
>>> par.
>>>
>>>
>>> I am sorry it is contorted thing :)
>>>>>
>>>>> Claudio
>>>>>
>>>>
>>> If instead you want to plot at y= -10 without changing xpd, then set
>>> axes=FALSE in the plot command and then construct your x and y axes
>>> separately to your specifications. Any more specific comments will  
>>> require
>>> that you present code (as well as a better description)  that  
>>> constructs an
>>> example.
>>>
>>> --
>>> David.
>>>
>>>
>>>>>
>>>>> 2011/8/25 R. Michael Weylandt <michael.weylandt at gmail.com>
>>>>>
>>>>> "lim" is not the argument: "ylim" is.
>>>>>>
>>>>>> You put in a vector of length 2 comprising the min and max y you  
>>>>>> wish:
>>>>>> consider this:
>>>>>>
>>>>>> x = -5:5; y = x^2; z = rep(-5,11);
>>>>>> layout(1:2)
>>>>>> plot(x,y,type="b"); lines(x,z,col=2)
>>>>>> plot(x,y,ylim = c(-8,max(y)+3),type="b"); lines(x,z,col=2)
>>>>>>
>>>>>> For your work, you'd need ylim = c(0, 1.03*max(y))  or something
>>>>>> similar.
>>>>>>
>>>>>> Michael Weylandt
>>>>>>
>>>>>>
>>>>>> On Thu, Aug 25, 2011 at 1:12 PM, Claudio Zanettini <
>>>>>> claudio.zanettini at gmail.com> wrote:
>>>>>>
>>>>>> Yes I tried but if I set the lim to 0 then it will not displayed  
>>>>>> the
>>>>>>> line
>>>>>>> that is at -10, right?
>>>>>>>
>>>>>>> 2011/8/25 R. Michael Weylandt <michael.weylandt at gmail.com>
>>>>>>>
>>>>>>> Look at ylim, as an optional argument to plot.
>>>>>>>
>>>>>>>>
>>>>>>>> Michael
>>>>>>>>
>>>>>>>> On Thu, Aug 25, 2011 at 1:07 PM, Claudio Zanettini <
>>>>>>>> claudio.zanettini at gmail.com> wrote:
>>>>>>>>
>>>>>>>> Hello everyone,
>>>>>>>>> I have a graph  and a segment parallel to the x axis  at  
>>>>>>>>> y=-10, x=0,
>>>>>>>>> and
>>>>>>>>> bars on it.
>>>>>>>>> Now the question is,
>>>>>>>>> Is there a way to leave the segment there but let the graph  
>>>>>>>>> axis
>>>>>>>>> start
>>>>>>>>> from
>>>>>>>>> the origin?
>>>>>>>>> In this way the segment will be out of the graph
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>>     [[alternative HTML version deleted]]
>>>>>>>>>
>>>>>>>>> ______________________________**________________
>>>>>>>>> R-help at r-project.org mailing list
>>>>>>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help 
> >>>>>>>> >
>>>>>>>>> PLEASE do read the posting guide
>>>>>>>>> http://www.R-project.org/**posting-guide.html<http://www.R-project.org/posting-guide.html 
> >>>>>>>> >
>>>>>>>>> and provide commented, minimal, self-contained, reproducible  
>>>>>>>>> code.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>       [[alternative HTML version deleted]]
>>>>
>>>> ______________________________**________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help 
> >>> >
>>>> PLEASE do read the posting guide http://www.R-project.org/**
>>>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>> David Winsemius, MD
>>> West Hartford, CT
>>>
>>>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
> 
> David Winsemius, MD
> West Hartford, CT
> 
> ______________________________________________
> 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.
> 


--
View this message in context: http://r.789695.n4.nabble.com/Segment-out-of-the-Graph-tp3768855p3771199.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list