1
votes

I have a data.frame where the data I have collected is seconds and I plot it on the y-axis. however when I want to plot that data, I want it do plotted with milliseconds as the unit on y-axis.

How can I modify the values which occur in the y-axis so they are 1000 times bigger than the data which actually occurs, while the plotted points remain the same?

This is the code which I use at the moment:

ggplot(DSRCdelay_cl, aes(x=numVehicles, y=value, colour=as.factor(clusteringDistance)  )  ) +
  geom_smooth(fill=NA, aes(group=clusteringDistance, size=0 ) ) +
  xlab(expression( "Vehicles (per" ~km^2~")" ) ) + 
  ylab("DSRC delay") + scale_y_continuous() + 
  expand_limits(x =c(0), y =c(0,0.1) )

Other answers which closely answer this question are: transforming axis labels with a multiplier ggplot2 and: ggplot2 axis transformation by constant factor

2

2 Answers

2
votes

Using a function which multiples the label values of the y-axis:

p + scale_y_continuous( labels=function(x)x*1000 )

0
votes

Axis text and label size can be changed with axis.text= and axis.title= in function theme(). To only change y axis title size, specify axis.title.y= As in the following:

g+theme(axis.text=element_text(size=12),
     axis.title.y=element_text(size=14,face="bold"))

Here are good refs for formatting ggplot graphs:

http://www.cookbook-r.com/Graphs/index.html

http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/