Skip to main content

The python version of JSONGrapher with tools for creating JSONGrapher Records.

Project description

JSONGrapher (python)

This is the python version of JSONGrapher with JSONRecordCreator. This package is for plotting JSON records with drag and drop and has tools for creating the JSON records.

The software will automatically plot multiple records together, for comparison, and will automaticlaly converting units between records as needed to plot them for comparison (like kg/s and g/s).

To use python JSONGrapher, first install it using conda or pip:
pip install JSONGrapher[COMPLETE] or conda install conda-forge::jsongrapher
Alternatively, you can download the directory directly.

0. Plotting a JSON Record

It's as simple as one line! Then drag an example JSONGrapher record into the window to plot! Below shows several plot types for 2D and 3D plots, followed by a simple example of how to use python JSONGrapher to create your own records.

import JSONGrapher 
JSONGrapher.launch()

JSONGRapher window JSONGRapher plot

rainbow plot mesh3d plot scatter3d plot bubble plot

1. Preparing to Create a Record

The remainder of this landing page follows a json record tutorial example file which shows how to create graphable .json records. The records can then be plotted with python JSONGrapher or with jsongrapher.com

Let's create an example where we plot the height of a pear tree over several years.

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 a record 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 plot the data using Matplotlib and export the plot as a PNG file.

Record.plot_with_matplotlib()
Record.export_to_matplotlib_png("image_from_tutorial_matplotlib_fig")

We can create an interactive graph with python plotly:

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

JSONGRapher record plotted using matplotlib

You can also see more examples: https://github.com/AdityaSavara/jsongrapher-py/tree/main/examples

Additionally, json records you send to others can be plotted by them at www.jsongrapher.com This 'see the plot using a browser' capability is intended to facilitate including JSONGrapher records in supporting information of scientific publications.

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

jsongrapher-3.7.tar.gz (75.2 kB view details)

Uploaded Source

Built Distribution

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

jsongrapher-3.7-py3-none-any.whl (80.0 kB view details)

Uploaded Python 3

File details

Details for the file jsongrapher-3.7.tar.gz.

File metadata

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

File hashes

Hashes for jsongrapher-3.7.tar.gz
Algorithm Hash digest
SHA256 c0820cb94fc0d8e953e4d8a4b940c751db7cce0d79043ff84f2401f90e860056
MD5 56422c969fc0762c470b29c75d5dd01d
BLAKE2b-256 95f5aad55e22acd03f1bb5d67d754f3fea0ed8fe23165533fa15ac55751dd430

See more details on using hashes here.

File details

Details for the file jsongrapher-3.7-py3-none-any.whl.

File metadata

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

File hashes

Hashes for jsongrapher-3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ac11bf612aab272b4b428d6a00f278fa2ae06a48e212364deb1635bc1f0ac7e9
MD5 d844f5c509d04c8aacc349678eef7f5c
BLAKE2b-256 a851968f03d6c3b170b019108518531a9dc4d170356e0ca4e0b2cb591aba298a

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