[R] Help me with R plotting

baptiste Auguié baptiste.auguie at googlemail.com
Thu Nov 18 16:34:13 CET 2010


Hi, 


Try this,

robots <- data.frame(id=letters[1:20],
                     x=rnorm(20),
                     y=rnorm(20),
                     consumption=runif(20, 10, 100))

library(ggplot2)

ggplot(robots) +
  geom_point(aes(x, y, colour=cut(consumption, c(0, 30, 50, 100)))) +
  geom_text(aes(x, y, colour=cut(consumption, c(0, 30, 50, 100)),
                label=round(consumption, 2)), vjust=1, legend=FALSE) +
  labs(colour="consumption")

      
HTH,

baptiste


On Nov 18, 2010, at 4:18 PM, Alaios wrote:

> Thanks a lot for your help
> 
> I tried first this
> test<-(myvalues)-mean(myvalues)
> 
> so to put the values close to the 0...30 scale...
> then I passed this as an argument
> 
> plot(x,y,col=test)
> 
> which plots the places where the robots are with a small color. I think this is ok for now. What I want next is also to plot some color bar so the reader can by inspecting first this color bar to say "Ah the read is for the range of 5-10 watts"
> 
> Also I tried legend... which creates small boxes below the dots which is Do not what I want exactly. I would like below every plot to write some text but not inside any box that will cover part of the image.
> 
> Best Regards
> Alex
> 
> --- On Thu, 11/18/10, Tal Galili <tal.galili at gmail.com> wrote:
> 
> From: Tal Galili <tal.galili at gmail.com>
> Subject: Re: [R] Help me with R plotting
> To: "Alaios" <alaios at yahoo.com>
> Cc: "Rhelp" <r-help at r-project.org>
> Date: Thursday, November 18, 2010, 2:13 PM
> 
> ?plotWill give a good solution
> #Example:set.seed(5)xx <- data.frame(x = runif(50), y = runif(50), z = sample(c(1:3), 50, T))with(xx, plot(x, y, col = z, pch = 19))
> 
> 
> Now you can start going into how to play with the colors, and how to add ?legend to the image...
> Tal
> 
> 
> ----------------Contact Details:-------------------------------------------------------
> 
> 
> Contact me: Tal.Galili at gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
> 
> 
> ----------------------------------------------------------------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> Hello everyone.
> 
> I want some help with plots.
> 
> I have some robots in an area. Every robot is placed on x,y coordinates and every robot has a power consumption of some watts. I would like to show where are the robots by showing in a map dots (where every dots is the x,y coordinate).
> 
> 
> 
> Below that dot it would be nice to write the watt consumption but also use some colors to denote different classes of consumption. So 10-20watt should be denoted by blue 20-30 with red, 30-40 with pink and so on.
> 
> 
> 
> Which is the appropriate plot function for that?
> 
> 
> 
> Regards
> 
> Alex
> 
> 
> 
> 
> 
> 
> 
> 
> 
>        [[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.
> 
> 
> 
> 
> 
> 
> 
> 	[[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.



More information about the R-help mailing list