hysteresis plot

291 views
Skip to first unread message

Ito, Kaori (Groton)

unread,
Nov 13, 2012, 8:50:25 AM11/13/12
to ggp...@googlegroups.com

Hello,

It may be a very simple question,….but how I can create a hyterisis plot (counter clockwise), for example, drug effect (PD) is observed later (=delayed) than the actual drug concentration (PK), and when PK vs. PD is plotted with line, it shows hysteresis.

Here is a small, toy example. I can create a hyterisis plot with xyplot, but the line is connected with the order of x-variable with ggplot so can’t produce what I want (I want to connect the line with the order of TIME)…..I tried reorder, relevel, but it doesn’t work (or maybe I am doing wrong).  

Could anybody help me?

Kaori

 

#example data

d <- data.frame(ID=rep(1:2, each=10), TIME=rep(c(0,0.5,1,2,4,6,8,12,16,24),2),

          PK=c(0,2,6,20,50,40,20,10,5,3,0,1,3,12,30,35,20,5,4,1),

          PD=c(100,102,105,110,120,130,160,150,140,135,60,65,70,75,80,95,100,90,85,70))

 

library(lattice)

xyplot(PD~PK, data=d, type="b", group=ID)

library(ggplot2)

d$ID <- as.factor(d$ID)

ggplot(d, aes(x= PK, y=PD, group=ID, colour=ID)) + geom_line()

 

 

 

ONKELINX, Thierry

unread,
Nov 13, 2012, 10:41:45 AM11/13/12
to Ito, Kaori (Groton), ggp...@googlegroups.com

Use geom_path() instead of geom_line().

 

ir. Thierry Onkelinx

Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest

team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance

Kliniekstraat 25

1070 Anderlecht

Belgium

+ 32 2 525 02 51

+ 32 54 43 61 85

Thierry....@inbo.be

www.inbo.be

 

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.

~ Sir Ronald Aylmer Fisher

 

The plural of anecdote is not data.

~ Roger Brinner

 

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.

~ John Tukey

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
Reply all
Reply to author
Forward
0 new messages