[R] Need help with plotting the graph

Jim Lemon jim at bitwrit.com.au
Mon Oct 7 22:31:44 CEST 2013


On 10/07/2013 09:02 PM, Prasad Joshi wrote:
> Hello All,
> ....
> I would like Y axis to represent BW and X axis to represent disk, vmfs and vmdk.
>
> All the examples in books or online have single X axis. I could not
> find an example which does something similar to what I am trying. Can
> anyone please give me some pointers?
>
Hi Prasad,
You may want something like the following:

df<-read.table(
  text="disk vmfs  vmdk     IOPS       BW
  naa.5000a7203007ed8f    3 eager 16886.77 65.96393 

  naa.5000a7203007ed8f    3  lazy 44623.15 174.3092
  naa.5000a7203007ed8f    5 eager 16767.53 65.49815
  naa.5000a7203007ed8f    5  lazy 45891.55 179.2639",
  header=TRUE)
x11(width=10,height=5)
par(mfrow=c(1,3))
brkdn_disk<-by(df$BW,df$disk,FUN=mean)
plot(brkdn_disk,xaxt="n")
axis(1,at=1:length(brkdn_disk),labels=names(brkdn_disk))
brkdn_vmfs<-by(df$BW,df$vmfs,FUN=mean)
plot(brkdn_vmfs,xaxt="n")
axis(1,at=1:length(brkdn_vmfs),labels=names(brkdn_vmfs))
brkdn_vmdk<-by(df$BW,df$vmdk,FUN=mean)
plot(brkdn_vmdk,xaxt="n")
axis(1,at=1:length(brkdn_vmdk),labels=names(brkdn_vmdk))

You can also have the plots in a vertical format by using:

par(mfrow=c(3,1))

Jim



More information about the R-help mailing list