0

I'm currently trying to write a program that will visualize numbers from a json file. I'm still a big rookie with coding, so i hope it will be an "easy" fix. The code im using looks like this:

dictionary = json.load(open('1D1.json', 'r'))
xAxis = [key for key, value in dictionary.items()]
yAxis = [value for key, value in dictionary.items()]
plt.grid(True)

## LINE GRAPH ##
plt.plot(xAxis, yAxis, color='maroon', marker='o')
plt.xlabel('Time')
plt.ylabel('Torque')

plt.show()

The json file im trying to read looks like this, but with a lot of data points:

{
    "XML_Data": {
        "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
        "@xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
        "Wsk3Header": {
            "Version": null,
            "Date": "2000-01-01",
            "Time": "00:00:00",
            "Title": "C30S V3 Curve",
            "NumberofYAxes": "5",
            "NumberOfVectors": "1926",
            "Controller": {
                "Type": null,
                "Id": null
            },
            "ProcessProg": {
                "Number": "0",
                "Name": null,
                "Type": null
            },
            "Result": {
                "Cycle": "0",
                "PartID": null,
                "Kind": null,
                "NumericalResultList": null
            }
        },
        "Wsk3Vectors": {
            "X_Axis": {
                "_Index": "0",
                "Header": {
                    "Name": "Time",
                    "Unit": "ms"
                },
                "Values": {
                    "float": [
                        "0",
                        "1",
                        "2",
.....

                        "1923",
                        "1924",
                        "1925"
                    ]
                }
            },
            "Y_AxesList": {
                "AxisData": [
                    {
                        "_Index": "0",
                        "Header": {
                            "Name": "Nset",
                            "Unit": "1/min"
                        },
                        "Values": {
                            "float": [
                                "0",
                                "4",
                                "8",
                                "12",
                                "16",
....

When i try to run the code i get an error message: TypeError: unhashable type: 'dict' and i don't know where the error is coming from.

I dont really know how to make the code read the json file properly, if i for example want the code to make a graph with nset on the y axis and time on the x axis.

0 Answers0