Skip to main content

Plot time-series data from line-delimited JSON.

Project description

foxplot

Build Documentation Coverage PyPI version

Plot time series from newline-delimited JSON.

Installation

pip install foxplot

Usage

Foxplot starts in interactive mode by default, which allows us to explore the input gathered in the data object (tab completion works: type data.<TAB> to explore) and plot times series from it using the fox.plot function:

$ foxplot upkie_2023-05-03-103245.mpack
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: fox.plot(data.observation.imu.angular_velocity)

This call will open a new tab in your browser with a plot of the time series. In this example, angular_velocity is a 3D vector, thus the plot will include three curves.

Plotting from files

We can also plot data from files and pipes directly, for example:

  • JSON: foxplot my_data.json -l /observation/cpu_temperature
  • MessagePack: foxplot my_data.mpack -l /observation/cpu_temperature

Richer plot

Here is a more complex plot with both left- and right-axis time series:

In [2]: fox.plot(
   ...:     [
   ...:         data.observation.servo.left_knee.position,
   ...:         data.observation.servo.left_wheel.position,
   ...:     ],
   ...:     right=[
   ...:         data.observation.servo.left_knee.velocity,
   ...:         data.observation.servo.left_wheel.velocity,
   ...:     ],
   ...:     left_axis_unit="rad",
   ...:     right_axis_unit="rad/s",
   ...:     print_command_line=True,
   ...: )

This call will output a command line to directly reproduce the plot:

The command line to generate this plot is:

foxplot upkie_2023-05-03-103245.mpack -l /observation/servo/left_knee/torque /observation/servo/left_wheel/torque -r /observation/servo/left_knee/velocity /observation/servo/left_wheel/velocity

Check out the other arguments to fox.plot, for instance in the IPython shell by fox.plot?.

Tips

Zsh users can filter foxplot completion on JSON and MessagePack files:

zstyle ":completion:*:*:foxplot:*" ignored-patterns "^*.(json|mpack)"

See also

  • µPlot's performance was a key enabler for this project.
  • rq, a tool to manipulate streams of records in various formats.

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

foxplot-0.5.0.tar.gz (79.1 kB view details)

Uploaded Source

Built Distribution

foxplot-0.5.0-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

Details for the file foxplot-0.5.0.tar.gz.

File metadata

  • Download URL: foxplot-0.5.0.tar.gz
  • Upload date:
  • Size: 79.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for foxplot-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3f6c926c2676784b016a64f4bf50d995274ffc39a2c7792274d44e01b0a1abdb
MD5 85ed67acf4d4f944f0c615e5a74ec493
BLAKE2b-256 f684c6afa12cc47114c23019e46ce9b3aa6d731af6867d964b1cf5ada9b3579e

See more details on using hashes here.

File details

Details for the file foxplot-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: foxplot-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 54.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for foxplot-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d7e7700934b139cc709dca9e6f30818bbbf4f52da233e1bd4a0ee4a53d9fab0
MD5 f486c92d5c972f7b13f046045734ae46
BLAKE2b-256 3e61d5f72c881305cd6f83d854ea460a30b3fe7b58faccec66e58449bc602a9c

See more details on using hashes here.

Supported by

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