Re: [R] dotplot: labeling coordinates for each point

2009-05-08 Thread Qifei Zhu
Thank you Deepayan! It works perfectly.

Best,
Tony

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Deepayan Sarkar
Sent: Thursday, May 07, 2009 12:20 PM
To: Qifei Zhu
Cc: r-help@r-project.org
Subject: Re: [R] dotplot: labeling coordinates for each point

On Thu, May 7, 2009 at 7:42 AM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,



 I guess I’m quite confusing when asking the question. I was actually looking
 for labels beside the dot in the graph (shown below), rather than the labels
 on the x-axis. Is that possible? Thanks a lot!

In that case

dotplot(y ~ x, xlab=Store, ylab=Revenue, main=test,
scales=list(x = list(draw = FALSE)),
panel = function(x, y, ...) {
panel.dotplot(x, y, ...)
id - y  90
panel.text(as.numeric(x[id]), y[id],
   labels = sprintf((%s,%g), as.character(x[id]), y[id]),
   pos = 4)
})

-Deepayan






 Best,

 Tony





 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Deepayan Sarkar
 Sent: Thursday, May 07, 2009 1:44 AM
 To: Qifei Zhu
 Cc: r-help@r-project.org
 Subject: Re: [R] dotplot: labeling coordinates for each point



 On Wed, May 6, 2009 at 6:54 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:

 Hi Deepayan,



 Thanks for the reply. here is a very simple example of what I'm looking
 for:



 y=c(100,0,-20)

 x=c(Atlanta, Baltimore, Berkeley CA)

 dotplot(y~x, xlab=Store, ylab=Revenue,main=test,
 scale=list(rot=60))



 Basically it produces a graph of city on the x-axis and its associated
 revenue

 on the y-axis. In the real data set, the x-axis will be filled of tens or
 even hundreds

 of cities, so I wanna label the dots in the graph whenever the revenue (y
 value) is

 greater than a threshold, let's say 90 in this case. The labels should be
 in (x,y)

 format, which is (Atlanta, 100) in this case. Appreciate a lot for your
 help!



 dotplot(y~x, xlab=Store, ylab=Revenue,main=test,

 xlim = ifelse(y  90, sprintf((%s,%g), x, y), ),

 scales=list(rot=60))



 -Deepayan







 Best,

 Tony



 -Original Message-

 From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com]

 Sent: Wednesday, May 06, 2009 8:40 PM

 To: Qifei Zhu

 Cc: David Winsemius; r-help@r-project.org

 Subject: Re: [R] dotplot: labeling coordinates for each point



 On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:

 Hi Deepayan,



 Thanks for the hint. I spent some time on the research but haven't got
 any luck in writing the custom panel function for the conditional labeling
 of points in a graph. Could you please provide some more thoughts and
 probably some pseudo code? Thank you so much for your time!





 I'll be happy to try if you provide a reproducible example.



 -Deepayan







 __

 R-help@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.

__
R-help@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.

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-05-07 Thread Deepayan Sarkar
On Thu, May 7, 2009 at 7:42 AM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,



 I guess I’m quite confusing when asking the question. I was actually looking
 for labels beside the dot in the graph (shown below), rather than the labels
 on the x-axis. Is that possible? Thanks a lot!

In that case

dotplot(y ~ x, xlab=Store, ylab=Revenue, main=test,
scales=list(x = list(draw = FALSE)),
panel = function(x, y, ...) {
panel.dotplot(x, y, ...)
id - y  90
panel.text(as.numeric(x[id]), y[id],
   labels = sprintf((%s,%g), as.character(x[id]), y[id]),
   pos = 4)
})

-Deepayan






 Best,

 Tony





 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Deepayan Sarkar
 Sent: Thursday, May 07, 2009 1:44 AM
 To: Qifei Zhu
 Cc: r-help@r-project.org
 Subject: Re: [R] dotplot: labeling coordinates for each point



 On Wed, May 6, 2009 at 6:54 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:

 Hi Deepayan,



 Thanks for the reply. here is a very simple example of what I'm looking
 for:



 y=c(100,0,-20)

 x=c(Atlanta, Baltimore, Berkeley CA)

 dotplot(y~x, xlab=Store, ylab=Revenue,main=test,
 scale=list(rot=60))



 Basically it produces a graph of city on the x-axis and its associated
 revenue

 on the y-axis. In the real data set, the x-axis will be filled of tens or
 even hundreds

 of cities, so I wanna label the dots in the graph whenever the revenue (y
 value) is

 greater than a threshold, let's say 90 in this case. The labels should be
 in (x,y)

 format, which is (Atlanta, 100) in this case. Appreciate a lot for your
 help!



 dotplot(y~x, xlab=Store, ylab=Revenue,main=test,

     xlim = ifelse(y  90, sprintf((%s,%g), x, y), ),

     scales=list(rot=60))



 -Deepayan







 Best,

 Tony



 -Original Message-

 From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com]

 Sent: Wednesday, May 06, 2009 8:40 PM

 To: Qifei Zhu

 Cc: David Winsemius; r-help@r-project.org

 Subject: Re: [R] dotplot: labeling coordinates for each point



 On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:

 Hi Deepayan,



 Thanks for the hint. I spent some time on the research but haven't got
 any luck in writing the custom panel function for the conditional labeling
 of points in a graph. Could you please provide some more thoughts and
 probably some pseudo code? Thank you so much for your time!





 I'll be happy to try if you provide a reproducible example.



 -Deepayan







 __

 R-help@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.

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-05-06 Thread Deepayan Sarkar
On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,

 Thanks for the hint. I spent some time on the research but haven't got any 
 luck in writing the custom panel function for the conditional labeling of 
 points in a graph. Could you please provide some more thoughts and probably 
 some pseudo code? Thank you so much for your time!


I'll be happy to try if you provide a reproducible example.

-Deepayan

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-05-06 Thread Qifei Zhu
Hi Deepayan,

Thanks for the reply. here is a very simple example of what I'm looking for:

 y=c(100,0,-20)
 x=c(Atlanta, Baltimore, Berkeley CA)
 dotplot(y~x, xlab=Store, ylab=Revenue,main=test, scale=list(rot=60))

Basically it produces a graph of city on the x-axis and its associated revenue 
on the y-axis. In the real data set, the x-axis will be filled of tens or even 
hundreds of cities, so I wanna label the dots in the graph whenever the revenue 
(y value) is greater than a threshold, let's say 90 in this case. The labels 
should be in (x,y) format, which is (Atlanta, 100) in this case. Appreciate a 
lot for your help!

Best,
Tony

-Original Message-
From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com] 
Sent: Wednesday, May 06, 2009 8:40 PM
To: Qifei Zhu
Cc: David Winsemius; r-help@r-project.org
Subject: Re: [R] dotplot: labeling coordinates for each point

On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,

 Thanks for the hint. I spent some time on the research but haven't got any 
 luck in writing the custom panel function for the conditional labeling of 
 points in a graph. Could you please provide some more thoughts and probably 
 some pseudo code? Thank you so much for your time!


I'll be happy to try if you provide a reproducible example.

-Deepayan

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-05-06 Thread Deepayan Sarkar
On Wed, May 6, 2009 at 6:54 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,

 Thanks for the reply. here is a very simple example of what I'm looking for:

 y=c(100,0,-20)
 x=c(Atlanta, Baltimore, Berkeley CA)
 dotplot(y~x, xlab=Store, ylab=Revenue,main=test, scale=list(rot=60))

 Basically it produces a graph of city on the x-axis and its associated revenue
 on the y-axis. In the real data set, the x-axis will be filled of tens or 
 even hundreds
 of cities, so I wanna label the dots in the graph whenever the revenue (y 
 value) is
 greater than a threshold, let's say 90 in this case. The labels should be in 
 (x,y)
 format, which is (Atlanta, 100) in this case. Appreciate a lot for your help!

dotplot(y~x, xlab=Store, ylab=Revenue,main=test,
xlim = ifelse(y  90, sprintf((%s,%g), x, y), ),
scales=list(rot=60))

-Deepayan



 Best,
 Tony

 -Original Message-
 From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com]
 Sent: Wednesday, May 06, 2009 8:40 PM
 To: Qifei Zhu
 Cc: David Winsemius; r-help@r-project.org
 Subject: Re: [R] dotplot: labeling coordinates for each point

 On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi Deepayan,

 Thanks for the hint. I spent some time on the research but haven't got any 
 luck in writing the custom panel function for the conditional labeling of 
 points in a graph. Could you please provide some more thoughts and probably 
 some pseudo code? Thank you so much for your time!


 I'll be happy to try if you provide a reproducible example.

 -Deepayan



__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-04-26 Thread Qifei Zhu
Hi David,

Thanks! It looks much better now. but is there any way to add (x,y)
coordinates as labels to all the points in the graph? Best case if I can
enforce some conditions saying if (y10,000) label, else no label. Any
advice is appreciated.

Best,
Tony

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Friday, April 24, 2009 10:48 PM
To: Qifei Zhu
Cc: r-help@r-project.org
Subject: Re: [R] dotplot: labeling coordinates for each point


On Apr 24, 2009, at 9:23 PM, Qifei Zhu wrote:
 I used dotplot to draw a graph for a dataset with size of 100. Since  
 the
 x-axis are all texts, so they are mixed up and not readable. Is  
 there any
 way to make it readable or how can I add labels to all the points  
 with its
 (x,y) coordinates? Thanks for your help.

Look up information on the scales parameter and rotate your label text:

dotplot(decrease ~ treatment, OrchardSprays, groups = rowpos,  
scales=list(x=list(rot=60,  
labels=c(,,,,,,,) )))

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-04-26 Thread Deepayan Sarkar
On 4/26/09, Qifei Zhu zhu_qi...@yahoo.com.sg wrote:
 Hi David,

  Thanks! It looks much better now. but is there any way to add (x,y)
  coordinates as labels to all the points in the graph? Best case if I can
  enforce some conditions saying if (y10,000) label, else no label. Any
  advice is appreciated.

Sure, write a panel function. See the examples in ?xyplot.

-Deepayan

__
R-help@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.


[R] dotplot: labeling coordinates for each point

2009-04-24 Thread Qifei Zhu
Hi all,

 

I used dotplot to draw a graph for a dataset with size of 100. Since the
x-axis are all texts, so they are mixed up and not readable. Is there any
way to make it readable or how can I add labels to all the points with its
(x,y) coordinates? Thanks for your help.

 

Best,

Tony

 


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] dotplot: labeling coordinates for each point

2009-04-24 Thread David Winsemius


On Apr 24, 2009, at 9:23 PM, Qifei Zhu wrote:
I used dotplot to draw a graph for a dataset with size of 100. Since  
the
x-axis are all texts, so they are mixed up and not readable. Is  
there any
way to make it readable or how can I add labels to all the points  
with its

(x,y) coordinates? Thanks for your help.


Look up information on the scales parameter and rotate your label text:

dotplot(decrease ~ treatment, OrchardSprays, groups = rowpos,  
scales=list(x=list(rot=60,  
labels=c(,,,,,,,) )))


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.