eabanoz
eabanoz

Reputation: 351

ggplot continues x seconds

I have a table and I would like to plot it. My life in seconds variable is numeric and it show time difference between to objects.

cascade.table:
length  life_in_seconds3
1   139198203
3   47714708
1   46776392
1   41034850
2   40063448
5   37776731
1   38105980
1   37488547
1   34389557
6   32608514
1   31430765
2   27278210
1   28932405
1   29078062
23  24441561
1   23353395
2   22552443
1   21809240
1   16483510
1   19111928
1   18752499
1   17958592
1   16426723
3   15594449
1   15269252
1   15423532
4   13315463
2   14926285
1   12780000
1   14953966
3   13794529
1   12273450
5   13798971
1   10903317
4   11322193
1   9372348
1   12708675
2   8610904
1   9329576
1   10902982
1   11120310
1   9316336
1   10125846
1   7479874
10  7864926
1   9315742
1   8990284
1   9074320
1   8911194
1   5464467
1   5866542
1   6841212
1   4830175
1   3719581
1   5358070
1   5138062
5   5003821
4   2645769
20  2784868
1   3763553
2   3870646
1   2108302
3   3234607
1   3739991
1   2945143
2   3205637
2   3730733
1   3209214
1   3622886
1   3222092
1   5096675
5   6742497
1   3192981
1   3225696
1   3642696
1   3058827
1   3543478
1   2862296
1   3601749
1   2655058
6   3211110
20  3254159
2   4019874
1   6071764
1   4688079
1   1790892
3   3275798
1   2574781
1   1339553
1   1124344
1   1205886
2   5067442
1   3203061
2   3275844
7   1901089
1   6094151
1   873064
1   873044
1   3897446

I used this script for ggplot:

sp=ggplot(data = cascade.table,aes(x=cascade.table$life_in_seconds3, y=cascade.table$length))+
        geom_point()

it creates this plot: enter image description here

I added this line to fix x axis problem

sp+ scale_x_continuous(breaks = round(seq(min(cascade.table$life_in_seconds3), 
                                          max(cascade.table$life_in_seconds3), by = 86400)))

It creates this plot: enter image description here

I need to fix x axis and it should look like y axis.

Thanks,

Upvotes: 0

Views: 58

Answers (1)

Axeman
Axeman

Reputation: 35397

ggplot(data = cascade.table, aes(x = life_in_seconds3 / 3.15569e7, y = length))+
  geom_point() + xlab('Time in years')

enter image description here

Upvotes: 3

Related Questions