how to get a plot with year on x axis

how to get a plot with plotly with year on the x-axis
Thanks in advance.

data
TIME inflation
2011-01 9.302325
2011-02 8.823529
2011-03 8.823529
2011-04 9.411765
2011-05 8.72093
2011-06 8.620689
2011-07 8.426967
2011-08 8.988764
2011-09 10.05587
2011-10 9.392265
2011-11 9.340659
2011-12 6.486486
2012-01 5.319149
2012-02 7.567567
2012-03 8.648648
2012-04 10.21505
2012-05 10.16043
2012-06 10.05291
2012-07 9.84456
2012-08 10.30928
2012-09 9.137055
2012-10 9.59596
2012-11 9.547739
2012-12 11.16751
2013-01 11.61616
2013-02 12.0603
2013-03 11.44279
2013-04 10.2439
2013-05 10.67961
2013-06 11.05769
2013-07 10.84906
2013-08 10.74766
2013-09 10.69767
2013-10 11.05991
2013-11 11.46789
2013-12 9.132421
2014-01 7.239819
2014-02 6.726458
2014-03 6.696429
2014-04 7.079646
2014-05 7.017544
2014-06 6.493506
2014-07 7.234043
2014-08 6.751055
2014-09 6.302521
2014-10 4.979253
2014-11 4.115226
2014-12 5.85774
2015-01 7.172996
2015-02 6.302521
2015-03 6.276151
2015-04 5.785124
2015-05 5.737705
2015-06 6.097561
2015-07 4.365079
2015-08 4.347826
2015-09 5.13834
2015-10 6.324111
2015-11 6.719368
2015-12 6.324111
2016-01 5.905512
2016-02 5.533597
2016-03 5.511811
2016-04 5.859375
2016-05 6.589147
2016-06 6.130268
2016-07 6.463878
2016-08 5.30303
2016-09 4.135338
2016-10 3.345725
2016-11 2.592592
2016-12 2.230483
2017-01 1.858736
2017-02 2.621723
2017-03 2.61194
2017-04 2.214022
2017-05 1.090909
2017-06 1.083032
2017-07 1.785714
2017-08 2.517986
2017-09 2.888087
2017-10 3.23741
2017-11 3.971119
2017-12 4
2018-01 5.109489
2018-02 4.744525
2018-03 4.363636
2018-04 3.971119
2018-05 3.956835
2018-06 3.928571
2018-07 5.614035
2018-08 5.614035
2018-09 5.614035
2018-10 5.226481
2018-11 4.861111
2018-12 5.244755
2019-01 6.597222
2019-02 6.968641
2019-03 7.665505
2019-04 8.333333
2019-05 8.650519
2019-06 8.591065
2019-07 5.980066
2019-08 6.312293
2019-09 6.976744
2019-10 7.615894
2019-11 8.609271
2019-12 9.634551
2020-01 7.491857
2020-02 6.840391
2020-03 5.501618
2020-04 5.448718
2011-01 2.041423
2011-02 2.263205
2011-03 2.555525
2011-04 2.787714
2011-05 3.034394
2011-06 2.996128
2011-07 3.072039
2011-08 3.157208
2011-09 3.210369
2011-10 3.075928
2011-11 3.075564
2011-12 2.846685
2012-01 2.789017
2012-02 2.786633
2012-03 2.642377
2012-04 2.449071
2012-05 2.059573
2012-06 1.997092
2012-07 1.880444
2012-08 2.055649
2012-09 2.209592
2012-10 2.231532
2012-11 1.932853
2012-12 1.857566
2013-01 1.721937
2013-02 1.809322
2013-03 1.570608
2013-04 1.260553
2013-05 1.488957
2013-06 1.802176
2013-07 1.959779
2013-08 1.695505
2013-09 1.490616
2013-10 1.298578
2013-11 1.470191
2013-12 1.64177
2014-01 1.652425
2014-02 1.453217
2014-03 1.587444
2014-04 2.035616
2014-05 2.096583
2014-06 2.072791
2014-07 1.976012
2014-08 1.825887
2014-09 1.760401
2014-10 1.759956
2014-11 1.529932
2014-12 1.128697
2015-01 0.5932413
2015-02 0.6556672
2015-03 0.6901335
2015-04 0.5581597
2015-05 0.6854441
2015-06 0.7080568
2015-07 0.6896433
2015-08 0.6885187
2015-09 0.5425317
2015-10 0.6851313
2015-11 0.8236661
2015-12 0.9621603
2016-01 1.294771
2016-02 1.069416
2016-03 0.9492598
2016-04 0.9577153
2016-05 0.9387741
2016-06 1.016528
2016-07 0.9936033
2016-08 1.06621
2016-09 1.29305
2016-10 1.467816
2016-11 1.547397
2016-12 1.882142
2017-01 2.36268
2017-02 2.54527
2017-03 2.359728
2017-04 2.397274
2017-05 2.16035
2017-06 1.963182
2017-07 2.015625
2017-08 2.220744
2017-09 2.369608
2017-10 2.222969
2017-11 2.410191
2017-12 2.35061
2018-01 2.191579
2018-02 2.21602
2018-03 2.280655
2018-04 2.269676
2018-05 2.601478
2018-06 2.786355
2018-07 2.884236
2018-08 2.892126
2018-09 2.914581
2018-10 3.10266
2018-11 2.69955
2018-12 2.385685
2019-01 2.108378
2019-02 2.089516
2019-03 2.279703
2019-04 2.48231
2019-05 2.269679
2019-06 2.087387
2019-07 2.154025
2019-08 1.95854
2019-09 1.6776
2019-10 1.650414
2019-11 1.897782
2019-12 2.168654
2020-01 2.378901
2020-02 2.270975
2020-03 1.7371
2020-04 0.8869253

tf <-tempfile()
writeLines("TIME	inflation
2011-01	9.302325
2011-02	8.823529
2012-03	8.823529
2012-04	9.411765
2013-05	8.72093
2013-06	8.620689",tf)
mydf<-read.table(tf,
               header = TRUE)

library(lubridate)
library(dplyr)
library(plotly)

mydf2 <- mutate(mydf,
              time_dt = ymd(paste0(TIME,"-01")))

plot_ly(data=mydf2,
        type="scatter",
        mode="lines+markers",
        x=~time_dt,
        y=~inflation)
1 Like

how to make a line plot with same data and the same specifications.
Thanks in advance.

Do you mean that you didnt find my example helpful ?
Will this be your first R program, or do you have some experience ?

1 Like

i have working knowledge of R programming. i was trying to make plot but unable to make it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.