[R] Axes value format

John Kane jrkrideau at inbox.com
Tue May 8 21:20:08 CEST 2012


Actually I meant a working example and some data (See ?dput for a handy way to supply data)

It is also a good idea to include the information from sessionInfo()


 I think David W has a good approach.  

Otherwise you might just want to write the axis yourself.  

=============================
x  <- c(1000000, 2000000, 3000000)
y  <- c( 44556, 89112, 133668)

nms  <- c("1M", "2M", "3M")

plot(x,y, xaxt="n")
axis(1, x, labels=nms)
============================



John Kane
Kingston ON Canada


> -----Original Message-----
> From: vihanpandey at gmail.com
> Sent: Tue, 8 May 2012 20:23:21 +0200
> To: jrkrideau at inbox.com
> Subject: Re: [R] Axes value format
> 
> On 8 May 2012 19:47, John Kane <jrkrideau at inbox.com> wrote:
>> Quite likely, but we need to know what you are doing and what graphics
>> package you are using.
>> 
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>>  and provide commented, minimal, self-contained, reproducible code.
> 
> Frightfully sorry about that. I'm using R on a Mac, and its a simple
> plot using plot() which is taking values from a CSV file, let me
> illustrate for one dataset :
> 
> ======
> #!/usr/bin/Rscript
> 
> out_file = "foobar.pdf"
> pdf(out_file, height=8.5, width=11)
> 
> my_values <- read.csv("foo.csv",head=TRUE,sep=",")
> 
> plot(my_values$num_sims,
> 	my_values$exec_time,
> 	xlab="Number of Simulations",
> 	ylab="Execution Time(in milliseconds)",
> 	col="red",
> 	main="Execution Time for Simulations")
> 
> lines(my_values$num_sims,my_values$exec_time,col="red")
> 
> my_values2 <- read.csv("bar.csv",head=TRUE,sep=",")
> 
> lines(my_values2$num_sims,my_values2$exec_time,col="blue")
> points(my_values2$num_sims,my_values2$exec_time,col="blue")
> 
> 
> legend("topright",
> 	lty=c(1,1),
> 	  c("foo","bar"),
> 	  col=c("red","blue")
> 	  );
> 
> dev.off()
> 
> print(paste("Plot was saved in:", getwd()))
> ======
> 
> foo.csv and bar.csv have values like:
> 
> "num_sims","exec_time"
> 1000000,44556
> 2000000,89112
> 3000000,133668
> 
> etc.
> 
> Please let me know if you require any additional information.
> 
> Cheers!
> 
> - vihan
> 
>> 
>> John Kane
>> Kingston ON Canada
>> 
>> 
>>> -----Original Message-----
>>> From: vihanpandey at gmail.com
>>> Sent: Tue, 8 May 2012 19:29:45 +0200
>>> To: r-help at r-project.org
>>> Subject: [R] Axes value format
>>> 
>>> Hi all,
>>> 
>>> I have some graphs where the values on the X and Y axes are by default
>>> in exponent form like 2e+05 or 1.0e+07. Is it possible to make them in
>>> a more readable form like 10M for 1.0e+07 or 200K for 2e+05?
>>> 
>>> Thanks and Regards,
>>> 
>>> - vihan
>>> 
>>> ______________________________________________
>>> 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.
>> 
>> ____________________________________________________________
>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends
>> and family!
>> Visit http://www.inbox.com/photosharing to find out more!
>> 
>>

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails



More information about the R-help mailing list