What is Nostr?
ajrlewis
npub145d…9etj
2024-09-16 15:21:16
in reply to nevent1q…rcn4

ajrlewis on Nostr: My bad ... the units are different so can't plot them on the same graph in that way ...

My bad ... the units are different so can't plot them on the same graph in that way ... here's the updated code:

```python
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import requests


currency = "USD"

response = requests.get(
f"https://mempool.space/api/v1/historical-price?currency={currency}";
)
data = response.json()

df = pd.DataFrame(data["prices"])
df["time"] = pd.to_datetime(df["time"], unit="s")

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(df["time"], np.log2(df[currency]), color="Black", marker="o")
ax2.plot(df["time"], np.log10(df[currency]), color="#FF9900")

ax1.set_xlabel("Date")
ax1.set_ylabel(f"Log Base 2 Historical {currency} Price", color="Black")
ax2.set_ylabel(f"Log Base 10 Historical {currency} Price", color="#FF9900")

plt.show()
```

and the corresponding figure (i.e. it's the same shape):

Author Public Key
npub145dzzcseavt770mvc2xz3rvxh5w5znh3qcj8tkm3dw638m5pgwsq5q9etj