0

I am trying to make a plot and my data looks like this:

diversity position
113 2098776
116 4598777
67 5626222
200 6423068
...

and I used this script:

qplot(position, diversity, data = FILE)

but when plot appears, in x axis I see values like 0e+00 1e+07 , but i want to convert these values begin from 0 to 60 instead.. any guide please?

zara
  • 1,048
  • 3
  • 9
  • 19
  • 1
    How about this? http://stackoverflow.com/questions/11610377/how-do-i-change-the-formatting-of-numbers-on-an-axis-with-ggplot – Gopala Feb 23 '16 at 02:40

2 Answers2

2

Make sure you load the scales package library(scales) and then Try this qplot(position, diversity, data = yourdataframe) + scale_x_continuous(labels = comma)

Imran Ali
  • 2,223
  • 2
  • 28
  • 41
  • now units got realy huge like 10,000,000 40,000,000 how can I make it smaller? – zara Feb 23 '16 at 03:01
  • This would really be reproducing the answer of @Jack Aidley, as mentioned by @Gopala`qplot(position, diversity, data = yourdataframe) + scale_x_continuous(labels=fancy_scientific)`. Please note that `fancy_scientific` is the name of a function used to format labels on x-axis. You can find it [here](http://stackoverflow.com/questions/11610377/how-do-i-change-the-formatting-of-numbers-on-an-axis-with-ggplot) – Imran Ali Feb 23 '16 at 04:07
  • Another possibility is `qplot(position, diversity, data = yourdataframe) + scale_x_continuous(breaks = trans_breaks("log10", function(x) 10^x), labels = trans_format("log10", math_format(10^.x)))` – Imran Ali Feb 23 '16 at 04:25
2

you could rescale the data,

qplot(scales::rescale(position, c(0,60)), diversity, data = FILE)
baptiste
  • 75,767
  • 19
  • 198
  • 294