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):
Published at
2024-09-16 15:21:16Event JSON
{
"id": "9a4f8640be10837fd212e52a2956f3a03b5c70c4e437aae7389ee5286b0f67ec",
"pubkey": "ad1a216219eb17ef3f6cc28c288d86bd1d414ef1062475db716bb513ee8143a0",
"created_at": 1726500076,
"kind": 1,
"tags": [
[
"e",
"584196674e2e32c7830f1c28926bd7a8352c21a98358f3cdd115c0683822e548",
"",
"root"
],
[
"e",
"4f1cc9ca55f695cf4ef6eb86cc9d4649c02cd526c7192cfd6ca82b21ddafe0e9",
"",
"reply"
],
[
"p",
"ad1a216219eb17ef3f6cc28c288d86bd1d414ef1062475db716bb513ee8143a0",
"wss://nos.lol/",
"ajrlewis"
],
[
"p",
"4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f"
]
],
"content": "My bad ... the units are different so can't plot them on the same graph in that way ... here's the updated code:\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport requests\n\n\ncurrency = \"USD\"\n\nresponse = requests.get(\n f\"https://mempool.space/api/v1/historical-price?currency={currency}\"\n)\ndata = response.json()\n\ndf = pd.DataFrame(data[\"prices\"])\ndf[\"time\"] = pd.to_datetime(df[\"time\"], unit=\"s\")\n\nfig, ax1 = plt.subplots()\nax2 = ax1.twinx()\nax1.plot(df[\"time\"], np.log2(df[currency]), color=\"Black\", marker=\"o\")\nax2.plot(df[\"time\"], np.log10(df[currency]), color=\"#FF9900\")\n\nax1.set_xlabel(\"Date\")\nax1.set_ylabel(f\"Log Base 2 Historical {currency} Price\", color=\"Black\")\nax2.set_ylabel(f\"Log Base 10 Historical {currency} Price\", color=\"#FF9900\")\n\nplt.show()\n```\n\nand the corresponding figure (i.e. it's the same shape):\n\nhttps://m.primal.net/Krre.png ",
"sig": "82372f32434e5eac333c7cca99961ce4d72f1e2e7171aef7a165c4b855b914788841ee1e26f29da9f5c9f90eac1a66377b645005ad96b6ef2763ea9a473a8965"
}