1

I need help with my time series. I have this dataframe which is built in pandas:

          date  bitcoin  tether
91  2017-11-01   0.0444  0.0001
90  2017-11-02   0.0426  0.0000
89  2017-11-03   0.0181  0.0000
88  2017-11-04   0.0296  0.0000
87  2017-11-05   0.0035  0.0000
86  2017-11-06  -0.0582  0.0000
85  2017-11-07   0.0206  0.0000
84  2017-11-08   0.0481  0.0100

I would like to plot together tether and bitcoin movement in the same plot, and the time should be visualized in the x-axis. I would like that the Bitcoin and the Tether will be scaled in their own size. I would like to have something like this in the picture (created with matplotlib), but with the time shown in the axis. I don't care about the package, only the result.....I am using Python 2.7.

Tether vs Bitcoin Var%

enter image description here

Nihal
  • 5,262
  • 7
  • 23
  • 41
La_haine
  • 339
  • 1
  • 6
  • 18
  • 1
    The [pandas visualization docs](https://pandas.pydata.org/pandas-docs/stable/visualization.html) as well as the [matplotlib examples page](https://matplotlib.org/gallery/index.html) have many different code samples one can easily adapt to ones needs. – Mr. T Jul 28 '18 at 13:30

1 Answers1

5

This is just a standard plot():

df.set_index(pd.to_datetime(df.date), drop=True).plot()

plot

To add a grid and a secondary y axis, use plot() arguments:

df = df.set_index(pd.to_datetime(df.date), drop=True)
df.bitcoin.plot(grid=True, label="bitcoin", legend=True)
df.tether.plot(secondary_y=True, label="tether", legend=True)

plot2

andrew_reece
  • 20,390
  • 3
  • 33
  • 58
  • How could I add a grid? It's not the same as my figure. I would like to emphasize the different scale, in the left and in the right side. How couls I do that? – La_haine Jul 28 '18 at 13:12
  • That's wonderful. Thanks a lot. I don't know this package well, so I have some difficulties. The last thing is, should It be possible to align the zeros of both Y axis? I want to display the plot with the zeros aligned. – La_haine Jul 28 '18 at 13:45
  • You're welcome! There is no standard way to align the origins of the two axes, but there are some workarounds [here](https://stackoverflow.com/questions/10481990/matplotlib-axis-with-two-scales-shared-origin). Glad I could help - please mark this answer as accepted by clicking the checkmark to the left of the answer if it resolves your original problem. – andrew_reece Jul 28 '18 at 13:50