- Load the key-value pairs using the json module from the json file.
- Create a
DataFrame
using the key-value pairs, with orient="index"
which means keys will be the index and the values will be the rows.
- Now simply create your plot from the dataframe.
import pandas as pd
import json
import matplotlib.pyplot as plt
with open('temp.json', 'r') as file:
data_pairs = json.load(file)
dataframe = pd.DataFrame.from_dict(data_pairs, orient="index")
dataframe[:5].plot(legend=False, figsize=(3 , 3))
_ = plt.xticks(rotation=45)
dataframe[5:].plot(legend=False, figsize=(3 , 3))
_ = plt.xticks(rotation=45)
Plots


References:
- Orient