Skip to main content

A python package for creating JSONGrapher Records.

Project description

JSONGrapherRC (JSONGrapher Record Creator)

A python package for creating JSONGrapher files which can then be plotted.

To use JSONGrapherRC, first install it using pip:

pip install JSONGrapherRC[COMPLETE]

Alternatively, you can download the directory directly.

It is easiest to then follow the example file to see how to create graphable .json records and to plot them. The .json files can then be dragged into www.jsongrapher.com

1. Preparing to Create a Record

Let's create an example where we plot the height of a pear tree over several years. Assuming a pear tree grows approximately 0.40 meters per year, we'll generate sample data with some variation.

x_label_including_units = "Time (years)"
y_label_including_units = "Height (m)"
time_in_years = [0, 1, 2, 3, 4]
tree_heights = [0, 0.42, 0.86, 1.19, 1.45]

2. Creating and Populating a New JSONGrapher Record

Record = JSONRecordCreator.create_new_JSONGrapherRecord()
Record.set_comments("Tree Growth Data collected from the US National Arboretum")
Record.set_datatype("Tree_Growth_Curve")
Record.set_x_axis_label_including_units(x_label_including_units)
Record.set_y_axis_label_including_units(y_label_including_units)
Record.add_data_series(series_name="pear tree growth", x_values=time_in_years, y_values=tree_heights, plot_type="scatter_spline")
Record.set_graph_title("Pear Tree Growth Versus Time")

3. Exporting to File

We can export it to a .json file, which can then be used with JSONGrapher.

Record.export_to_json_file("ExampleFromTutorial.json")
Record.print_to_inspect()

Expected Output:

JSONGrapher Record exported to, ./ExampleFromTutorial.json
{
    "comments": "Tree Growth Data collected from the US National Arboretum",
    "datatype": "Tree_Growth_Curve",
    "data": [
        {
            "name": "pear tree growth",
            "x": [0, 1, 2, 3, 4],
            "y": [0, 0.42, 0.86, 1.19, 1.45],
            "type": "scatter",
            "line": { "shape": "spline" }
        }
    ],
    "layout": {
        "title": "Pear Tree Growth Versus Time",
        "xaxis": { "title": "Time (year)" },
        "yaxis": { "title": "Height (m)" }
    }
}

4. Plotting to Inspect

We can also plot the data using Matplotlib and export the plot as a PNG file.

Record.plot_with_matplotlib()
Record.export_to_matplotlib_png("ExampleFromTutorial_matplotlib_fig")

And we can create an interactive graph with plotly:

Record.plot_with_plotly() #Try hovering your mouse over points after this command!

JSONGRapher record plotted using matplotlib

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsongrapherrc-2.6.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsongrapherrc-2.6-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file jsongrapherrc-2.6.tar.gz.

File metadata

  • Download URL: jsongrapherrc-2.6.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jsongrapherrc-2.6.tar.gz
Algorithm Hash digest
SHA256 a5c93386467e04bda92d16656c0cde6f868d91eac625b217ef026534cac88696
MD5 c32b3266ecdd02cc47e6d248813cc7b4
BLAKE2b-256 73d704d27f9a48d37086cfdd01815d0c1c89bf7b93c95bc974637aa61c791232

See more details on using hashes here.

File details

Details for the file jsongrapherrc-2.6-py3-none-any.whl.

File metadata

  • Download URL: jsongrapherrc-2.6-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jsongrapherrc-2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7e659f1dc409948c2893feedeef76fe78c281340fe71262a79d704c99d5871d6
MD5 1d79e5881cc892f81401ed74468ff5fc
BLAKE2b-256 15652c5122d89a42559c36c09060f0646914590c7be27fc0841a420ad0bd4134

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page