Skip to main content

Create matplotlib and plotly charts with the same few lines of code.

Project description

interplot

License: GPL v3 Binder NBViewer

Create matplotlib and plotly charts with the same few lines of code.

It combines the best of the matplotlib and the plotly worlds through a unified, flat API.

Switch between matplotlib and plotly with the single keyword interactive. All the necessary boilerplate code to translate between the packages is contained in this module.

Currently supported building blocks:

  • scatter plots
    • line
    • scatter
    • linescatter
  • bar charts bar
  • histogram hist
  • boxplot boxplot
  • heatmap heatmap
  • linear regression regression
  • line fill fill
  • annotations text

Supported

  • 2D subplots
  • automatic color cycling
  • 3 different API modes
    • One line of code

      >>> interplot.line([0,4,6,7], [1,2,4,8])
      [plotly line figure]
      
      >>> interplot.hist(np.random.normal(40, 8, 1000), interactive=False)
      [matplotlib hist figure]
      
      >>> interplot.boxplot(
      >>>     [
      >>>         np.random.normal(20, 5, 1000),
      >>>         np.random.normal(40, 8, 1000),
      >>>         np.random.normal(60, 5, 1000),
      >>>     ],
      >>> )
      [plotly boxplots]
      
    • Decorator to auto-initialize plots to use in your methods

      >>> @interplot.magic_plot
      >>> def plot_my_data(fig=None):
      >>>     # import and process your data...
      >>>     data = np.random.normal(2, 3, 1000)
      >>>     # draw with the fig instance obtained from the decorator function
      >>>     fig.add_line(data, label="my data")
      >>>     fig.add_fill((0, 999), (-1, -1), (5, 5), label="sigma")
      
      >>> plot_my_data(title="My Recording")
      [plotly figure "My Recording"]
      
      >>> @interplot.magic_plot_preset(interactive=False, title="Preset Title")
      >>> def plot_my_data_preconfigured(fig=None):
      >>>     # import and process your data...
      >>>     data = np.random.normal(2, 3, 1000)
      >>>     # draw with the fig instance obtained from the decorator function
      >>>     fig.add_line(data, label="my data")
      >>>     fig.add_fill((0, 999), (-1, -1), (5, 5), label="sigma")
      
      >>> plot_my_data_preconfigured()
      [matplotlib figure "Preset Title"]
      
    • The interplot.Plot class for full control

      >>> fig = interplot.Plot(
      >>>     interactive=True,
      >>>     title="Everything Under Control",
      >>>     fig_size=(800, 500),
      >>>     rows=1,
      >>>     cols=2,
      >>>     shared_yaxes=True,
      >>>     # ...
      >>> )
      >>> fig.add_hist(np.random.normal(1, 0.5, 1000), row=0, col=0)
      >>> fig.add_boxplot(
      >>>     [
      >>>         np.random.normal(20, 5, 1000),
      >>>         np.random.normal(40, 8, 1000),
      >>>         np.random.normal(60, 5, 1000),
      >>>     ],
      >>>     row=0,
      >>>     col=1,
      >>> )
      >>> # ...
      >>> fig.post_process()
      >>> fig.show()
      [plotly figure "Everything Under Control"]
      
      >>> fig.save("export/path/file.html")
      saved figure at export/path/file.html
      

Resources

Licence

License: GPL v3

Demo

View on NBViewer: NBViewer

Try on Binder: Binder

Install

pip install interplot

dev installation

  1. git clone https://github.com/janjoch/interplot
  2. cd interplot
  3. pip install -e .

Contribute

Ideas, bug reports/fixes, feature requests and code submissions are very welcome! Please write to janjo@duck.com or directly into a pull request.

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

interplot-1.0.0.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

interplot-1.0.0-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file interplot-1.0.0.tar.gz.

File metadata

  • Download URL: interplot-1.0.0.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for interplot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 08c77524e66db3a306bdf1b7a6678fd9965131cc384cf1564bd5f40de3c6c2c2
MD5 ced79717821a3e62311315f67996296b
BLAKE2b-256 a71c049e7d7efcb6565b0853b1b00ccfb85360cde2c440531e2ac85a34b850bf

See more details on using hashes here.

File details

Details for the file interplot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: interplot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for interplot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8772b581cf9d991d98b55bb21eee4ccaf77059c3e2f0ace5b3a52c27ad9d816d
MD5 4c5bd7ef448993b35ec0f1a73a0eed06
BLAKE2b-256 1fc9af346ae85fc697356deda06ad26cc65e85c154ba6719c81832eb68e218fa

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