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.
To use python JSONGrapher, first install it using pip:
pip install JSONGrapher[COMPLETE]
Alternatively, you can download the directory directly.
0. Plotting a JSON Record
It's as simple as one line! Then drag a json record into the window to plot.
import JSONGrapher JSONGrapher.launch()
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 and to plot them. The .json files can then be dragged into the python JSONgrapher or into www.jsongrapher.com
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("image_from_tutorial_matplotlib_fig")
And we can create an interactive graph with plotly:
Record.plot_with_plotly() #Try hovering your mouse over points after this command!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsongrapher-2.8.tar.gz.
File metadata
- Download URL: jsongrapher-2.8.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaf0618ae8faf48456dda5b9425b93b31de91f270c81f0808e0397653c79a5ca
|
|
| MD5 |
21fc792ce69b3cae335dd54dc9731b6c
|
|
| BLAKE2b-256 |
956d4fdbda3ec87e8539418fd58a3af4e6a40e38607dd41949d6213030c0899a
|
File details
Details for the file jsongrapher-2.8-py3-none-any.whl.
File metadata
- Download URL: jsongrapher-2.8-py3-none-any.whl
- Upload date:
- Size: 42.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a27f426c74600e7f3659117a015d5d3e4e81decbf4b44407c6e11184f6a9b52
|
|
| MD5 |
6904961f85b460dde22525205883b15f
|
|
| BLAKE2b-256 |
9461b63c782d98ade2cf786b7a39fb7f911e737aeaf96ccb52d60aac0690d7e6
|