[R] dotplot: labeling coordinates for each point

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu May 7 07:44:06 CEST 2009


On Wed, May 6, 2009 at 6:54 PM, Qifei Zhu <zhu_qifei at 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.sarkar at gmail.com]
> Sent: Wednesday, May 06, 2009 8:40 PM
> To: Qifei Zhu
> Cc: David Winsemius; r-help at r-project.org
> Subject: Re: [R] dotplot: labeling coordinates for each point
>
> On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu <zhu_qifei at 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
>
>




More information about the R-help mailing list