uniplot


Nameuniplot JSON
Version 0.21.4 PyPI version JSON
download
home_pageNone
SummaryLightweight plotting to the terminal. 4x resolution via Unicode.
upload_time2025-08-03 07:43:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseCopyright (c) 2020 Olav Stetter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Uniplot
[![Build Status](https://github.com/olavolav/uniplot/actions/workflows/unit_tests.yml/badge.svg?branch=master)](https://github.com/olavolav/uniplot/actions?query=workflow%3A"Unit+Tests")
[![PyPI Version](https://badge.fury.io/py/uniplot.svg)](https://pypi.org/project/uniplot/)
[![PyPI Downloads](https://pepy.tech/badge/uniplot)](https://pepy.tech/project/uniplot)

Lightweight plotting to the terminal. 4x resolution via Unicode.

![uniplot demo GIF](https://github.com/olavolav/uniplot/raw/master/resource/uniplot-demo.gif)

When working with production data science code it can be handy to have plotting
tool that does not rely on graphics dependencies or works only in a Jupyter
notebook.

The **use case** that this was built for is to have plots as part of your data
science / machine learning CI/CD pipeline - that way whenever something goes
wrong, you get not only the error and backtrace but also plots that show what
the problem was.


## Features

* Unicode drawing, so 4x the resolution (pixels) of usual ASCII plots, or even
  8x when using Braille characters
* Super simple API
* Interactive mode (pass `interactive=True`)
* Color mode (pass `color=True`) useful in particular when plotting multiple series
* It's fast: Plotting 1M data points takes 26ms thanks to NumPy magic

Please note that Unicode drawing will work correctly only when using a font
that fully supports the [Block Elements character
set](https://en.wikipedia.org/wiki/Box-drawing_character) or the [Braille
character set](https://en.wikipedia.org/wiki/Braille_Patterns). Please refer to
[this page for a (incomplete) list of supported
fonts](https://www.fileformat.info/info/unicode/block/block_elements/fontsupport.htm)
and the options below to select the character set.


## Simple example


```python
import math
x = [math.sin(i / 20) + i / 300 for i in range(600)]
from uniplot import plot
plot(x, title="Sine wave")
```

Result:
```
                          Sine wave
┌────────────────────────────────────────────────────────────┐
│                                                    ▟▀▚     │
│                                                   ▗▘ ▝▌    │
│                                       ▗▛▜▖        ▞   ▐    │
│                                       ▞  ▜       ▗▌    ▌   │ 2
│                           ▟▀▙        ▗▘  ▝▌      ▐     ▜   │
│                          ▐▘ ▝▖       ▞    ▜      ▌     ▝▌  │
│              ▗▛▜▖        ▛   ▜      ▗▌    ▝▌    ▐▘      ▜  │
│              ▛  ▙       ▗▘   ▝▖     ▐      ▚    ▞       ▝▌ │
│  ▟▀▖        ▐▘  ▝▖      ▟     ▚     ▌      ▝▖  ▗▌        ▜▄│ 1
│ ▐▘ ▐▖       ▛    ▙      ▌     ▐▖   ▗▘       ▚  ▞           │
│ ▛   ▙      ▗▘    ▐▖    ▐       ▙   ▞        ▝▙▟▘           │
│▐▘   ▐▖     ▐      ▌    ▛       ▐▖ ▗▘                       │
│▞     ▌     ▌      ▐   ▗▘        ▜▄▛                        │
│▌─────▐────▐▘───────▙──▞────────────────────────────────────│ 0
│       ▌   ▛        ▝▙▟▘                                    │
│       ▜  ▐▘                                                │
│        ▙▄▛                                                 │
└────────────────────────────────────────────────────────────┘
         100       200       300       400       500       600
```

For more examples, please see the `examples/` folder.


## Parameters

The `plot` function accepts a number of parameters, all listed below. Note that
only `ys` is required, all others are optional.

There is also a `plot_to_string` function with the same signature, if you want
the result as a list of strings, to include the output elsewhere. The only
difference is that `plot_to_string` does not support interactive mode.


### Data

* `xs` - The x coordinates of the points to plot. Can either be `None`, or a
  list or NumPy array for plotting a single series, or a list of those for
  plotting multiple series. Defaults to `None`, meaning that the x axis will be
  just the sample index of `ys`.
* `ys` - The y coordinates of the points to plot. Can either be a list or NumPy
  array for plotting a single series, or a list of those for plotting multiple
  series.

In both cases, NaN or `None` values are ignored.

Note that since v0.12.0 you can also pass a list or an NumPy array of
timestamps, and the axis labels should be formatted correctly.


### Options

In alphabetical order:

#### Basic options

* `color` - Draw series in color. Defaults to `False` when plotting a single
  series, and to `True` when plotting multiple. Also accepts a list of colors,
  identified by strings like `"red"` for simple ANSI colors, tuples of RGB
  values like `(255,0,0)`, or hexadecimal RGB colors like `"#B4FBB8"`.
  Alternaively, you can specify a color theme as a string, as defined in
  `uniplot/color_themes.py`. Note that for RGB colors you need to use a
  terminal that supports them.
* `height` - The height of the plotting region, in characters. Default is `17`.
* `interactive` - Enable interactive mode. Defaults to `False`.
* `legend_labels` - Labels for the series. Can be `None` or a list of strings.
  Defaults to `None`.
* `lines` - Enable lines between points. Can either be `True` or `False`, or a
  list of Boolean values for plotting multiple series. Defaults to `False`.
* `title` - The title of the plot. Defaults to `None`.
* `width` - The width of the plotting region, in characters. Default is `60`.
  Note that if the `line_length_hard_cap` option (see "Advanced options" below)
  is used and there is not enough space, the actual width may be smaller.
* `x_max` - Maximum x value of the view. Defaults to a value that shows all
  data points.
* `x_min` - Minimum x value of the view. Defaults to a value that shows all
  data points.
* `x_unit` - Unit of the x axis. This is a string that is appended to the axis
  labels. Defaults to `""`.
* `y_max` - Maximum y value of the view. Defaults to a value that shows all
  data points.
* `y_min` - Minimum y value of the view. Defaults to a value that shows all
  data points.
* `y_unit` - Unit of the y axis. This is a string that is appended to the axis
  labels. Defaults to `""`.

#### Advanced options

* `character_set` - Which Unicode character set to use. Use `"block"` for
  the [Block Elements character
  set](https://en.wikipedia.org/wiki/Block_Elements) with 4x resolution, or
  `"braille"` for the [Braille character
  set](https://en.wikipedia.org/wiki/Braille_Patterns) with 8x resolution,
  `"ascii"` to use ASCII characters only. Braille has the highest resolution,
  and a lighter look overall. Defaults to `"block"`.
* `force_ascii_characters` -  List of characters to use when using the
  ASCII character set. Defaults to `["+", "x", "o", "*", "~", "."]`.
* `legend_placement` - Arrangement of the legend labels. `"auto"` attempts to
  place them one or more rows next to each other, while `"vertical"` is a
  block with one label per row. Defaults to `"auto"`.
* `line_length_hard_cap` - Enforce a hard limit on the number of characters per
  line of the plot area. This may override the `width` option if there is not
  enough space. Defaults to `None`.
* `rounded_corners` - Draw bounding box with round corners. Defaults to `False.
* `x_as_log` - Plot the x axis as logarithmic scale. Defaults to `False`.
* `x_gridlines` - A list of x values that have a vertical line for better
  orientation. Defaults to `[0]`, or to `[]` if `x_as_log` is enabled.
* `x_gridlines_color` - A boolean or a list of colors for the vertical
  gridlines, as specified above for the `color` option. Defaults to `False`.
* `x_labels` - Enable axis labels for the x axis. Defaults to `True`.
* `y_as_log` - Plot the y axis as logarithmic scale. Defaults to `False`.
* `y_gridlines` - A list of y values that have a horizontal line for better
  orientation. Defaults to `[0]`, or to `[]` if `y_as_log` is enabled.
* `y_gridlines_color` - A boolean or a list of colors for the horizontal
  gridlines, as specified above for the `color` option. Defaults to `False`.
* `y_labels` - Enable axis labels for the y axis. Defaults to `True`.


### Changing default parameters

uniplot does not store a state of the configuration parameters. However, you
can define a new plot funtion with new defaults by defining a `partial`. See
the following example:

```python
from functools import partial
from uniplot import plot as default_plot
plot = partial(default_plot, height=25, width=80)
```

This defines a new `plot` function that is identical to the original, except
the default values for `width` and `height` are now different.


## Experimental features

### Plotting histograms

For convenience there is also a `histogram` function that accepts one or more
series and plots bar-chart like histograms. It will automatically discretize
the series into a number of bins given by the `bins` option and display the
result.

Additional options, in alphabetical order:

* `bins` - Number of bins to use. Defaults to `20`.
* `bins_min` - Lower limit of the first bin. Defaults to the minimum of the
  series.
* `bins_max` - Upper limit of the last bin. Defaults to the maximum of the
  series.

When calling the `histogram` function, the `lines` option is `True` by default.

Example:

```python
import numpy as np
x = np.sin(np.linspace(1, 1000))
from uniplot import histogram
histogram(x)
```

Result:
```
┌────────────────────────────────────────────────────────────┐
│   ▛▀▀▌                       │                   ▐▀▀▜      │ 5
│   ▌  ▌                       │                   ▐  ▐      │
│   ▌  ▌                       │                   ▐  ▐      │
│   ▌  ▀▀▀▌                    │                ▐▀▀▀  ▝▀▀▜   │
│   ▌     ▌                    │                ▐        ▐   │
│   ▌     ▌                    │                ▐        ▐   │
│   ▌     ▙▄▄▄▄▄▖              │          ▗▄▄▄  ▐        ▐   │
│   ▌           ▌              │          ▐  ▐  ▐        ▐   │
│   ▌           ▌              │          ▐  ▐  ▐        ▐   │
│   ▌           ▌              │          ▐  ▐  ▐        ▐   │
│   ▌           ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜  ▐▀▀▀  ▝▀▀▀        ▐   │
│   ▌                          │    ▐  ▐                 ▐   │
│   ▌                          │    ▐  ▐                 ▐   │
│   ▌                          │    ▐▄▄▟                 ▐   │
│   ▌                          │                         ▐   │
│   ▌                          │                         ▐   │
│▄▄▄▌▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁│▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▐▄▄▄│ 0
└────────────────────────────────────────────────────────────┘
     -1                        0                       1
```

### Arrow keys and FPS-style keys

In interactive mode, we now also support wasd or FPS-style keyboard layout and
the arrow keys. Arrows should work on most platforms like Mac, Linux or Windows. We might make the keyboard layout fully configurable, to change the current Vim-inspired one, at a later date. For now, you have 3 ways to move the view:

* Vim-style: `h` left, `j` down, `k` up, `l` right, `u` zoom in, `n` zoom out.
* FPS-style: `a` left, `s` down, `w` up, `d` right, `]` zoom in, `[` zoom out.
* Arrow keys: movement obvious, `]` zoom in, `[` zoom out.


### Streaming

There is initial support for streaming using the `plot_gen` function. The idea
is have a class that wraps the plot function and the state of plotting, such
that we can `update` the state of the plot.

Example, assuming we had a function called `get_new_data` to get new data from
some source:
```python3
from uniplot import plot_gen

plt = plot_gen()
ys = []

while True:
    ys.append(get_new_data())
    plt.update(ys=ys, title=f"Streaming: {len(ys)} data point(s) ...")
```

See `examples/5-streaming.py` for a more complete example.


## Installation

Install via pip using:

```shell
pip install uniplot
```


## Contributing

Clone this repository, and make sure you
[have uv installed](https://docs.astral.sh/uv/getting-started/installation/).

On most Linux-like systems like MacOS you can run:
```shell
make
```
See the `Makefile` for details and more granular commands.

Alternatively, on systems like Windows that do not have `make` installed, you can run:
```shell
uv run scripts/run_tests.sh
```

Then proceed with issues, PRs etc. the usual way.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "uniplot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Olav Stetter <olav.stetter@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/71/cc/9ecf0d50960384d1dd818fb31d8a6b3ad62848fb0d29cd9c8b6345b90122/uniplot-0.21.4.tar.gz",
    "platform": null,
    "description": "# Uniplot\n[![Build Status](https://github.com/olavolav/uniplot/actions/workflows/unit_tests.yml/badge.svg?branch=master)](https://github.com/olavolav/uniplot/actions?query=workflow%3A\"Unit+Tests\")\n[![PyPI Version](https://badge.fury.io/py/uniplot.svg)](https://pypi.org/project/uniplot/)\n[![PyPI Downloads](https://pepy.tech/badge/uniplot)](https://pepy.tech/project/uniplot)\n\nLightweight plotting to the terminal. 4x resolution via Unicode.\n\n![uniplot demo GIF](https://github.com/olavolav/uniplot/raw/master/resource/uniplot-demo.gif)\n\nWhen working with production data science code it can be handy to have plotting\ntool that does not rely on graphics dependencies or works only in a Jupyter\nnotebook.\n\nThe **use case** that this was built for is to have plots as part of your data\nscience / machine learning CI/CD pipeline - that way whenever something goes\nwrong, you get not only the error and backtrace but also plots that show what\nthe problem was.\n\n\n## Features\n\n* Unicode drawing, so 4x the resolution (pixels) of usual ASCII plots, or even\n  8x when using Braille characters\n* Super simple API\n* Interactive mode (pass `interactive=True`)\n* Color mode (pass `color=True`) useful in particular when plotting multiple series\n* It's fast: Plotting 1M data points takes 26ms thanks to NumPy magic\n\nPlease note that Unicode drawing will work correctly only when using a font\nthat fully supports the [Block Elements character\nset](https://en.wikipedia.org/wiki/Box-drawing_character) or the [Braille\ncharacter set](https://en.wikipedia.org/wiki/Braille_Patterns). Please refer to\n[this page for a (incomplete) list of supported\nfonts](https://www.fileformat.info/info/unicode/block/block_elements/fontsupport.htm)\nand the options below to select the character set.\n\n\n## Simple example\n\n\n```python\nimport math\nx = [math.sin(i / 20) + i / 300 for i in range(600)]\nfrom uniplot import plot\nplot(x, title=\"Sine wave\")\n```\n\nResult:\n```\n                          Sine wave\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502                                                    \u259f\u2580\u259a     \u2502\n\u2502                                                   \u2597\u2598 \u259d\u258c    \u2502\n\u2502                                       \u2597\u259b\u259c\u2596        \u259e   \u2590    \u2502\n\u2502                                       \u259e  \u259c       \u2597\u258c    \u258c   \u2502 2\n\u2502                           \u259f\u2580\u2599        \u2597\u2598  \u259d\u258c      \u2590     \u259c   \u2502\n\u2502                          \u2590\u2598 \u259d\u2596       \u259e    \u259c      \u258c     \u259d\u258c  \u2502\n\u2502              \u2597\u259b\u259c\u2596        \u259b   \u259c      \u2597\u258c    \u259d\u258c    \u2590\u2598      \u259c  \u2502\n\u2502              \u259b  \u2599       \u2597\u2598   \u259d\u2596     \u2590      \u259a    \u259e       \u259d\u258c \u2502\n\u2502  \u259f\u2580\u2596        \u2590\u2598  \u259d\u2596      \u259f     \u259a     \u258c      \u259d\u2596  \u2597\u258c        \u259c\u2584\u2502 1\n\u2502 \u2590\u2598 \u2590\u2596       \u259b    \u2599      \u258c     \u2590\u2596   \u2597\u2598       \u259a  \u259e           \u2502\n\u2502 \u259b   \u2599      \u2597\u2598    \u2590\u2596    \u2590       \u2599   \u259e        \u259d\u2599\u259f\u2598           \u2502\n\u2502\u2590\u2598   \u2590\u2596     \u2590      \u258c    \u259b       \u2590\u2596 \u2597\u2598                       \u2502\n\u2502\u259e     \u258c     \u258c      \u2590   \u2597\u2598        \u259c\u2584\u259b                        \u2502\n\u2502\u258c\u2500\u2500\u2500\u2500\u2500\u2590\u2500\u2500\u2500\u2500\u2590\u2598\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2599\u2500\u2500\u259e\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502 0\n\u2502       \u258c   \u259b        \u259d\u2599\u259f\u2598                                    \u2502\n\u2502       \u259c  \u2590\u2598                                                \u2502\n\u2502        \u2599\u2584\u259b                                                 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n         100       200       300       400       500       600\n```\n\nFor more examples, please see the `examples/` folder.\n\n\n## Parameters\n\nThe `plot` function accepts a number of parameters, all listed below. Note that\nonly `ys` is required, all others are optional.\n\nThere is also a `plot_to_string` function with the same signature, if you want\nthe result as a list of strings, to include the output elsewhere. The only\ndifference is that `plot_to_string` does not support interactive mode.\n\n\n### Data\n\n* `xs` - The x coordinates of the points to plot. Can either be `None`, or a\n  list or NumPy array for plotting a single series, or a list of those for\n  plotting multiple series. Defaults to `None`, meaning that the x axis will be\n  just the sample index of `ys`.\n* `ys` - The y coordinates of the points to plot. Can either be a list or NumPy\n  array for plotting a single series, or a list of those for plotting multiple\n  series.\n\nIn both cases, NaN or `None` values are ignored.\n\nNote that since v0.12.0 you can also pass a list or an NumPy array of\ntimestamps, and the axis labels should be formatted correctly.\n\n\n### Options\n\nIn alphabetical order:\n\n#### Basic options\n\n* `color` - Draw series in color. Defaults to `False` when plotting a single\n  series, and to `True` when plotting multiple. Also accepts a list of colors,\n  identified by strings like `\"red\"` for simple ANSI colors, tuples of RGB\n  values like `(255,0,0)`, or hexadecimal RGB colors like `\"#B4FBB8\"`.\n  Alternaively, you can specify a color theme as a string, as defined in\n  `uniplot/color_themes.py`. Note that for RGB colors you need to use a\n  terminal that supports them.\n* `height` - The height of the plotting region, in characters. Default is `17`.\n* `interactive` - Enable interactive mode. Defaults to `False`.\n* `legend_labels` - Labels for the series. Can be `None` or a list of strings.\n  Defaults to `None`.\n* `lines` - Enable lines between points. Can either be `True` or `False`, or a\n  list of Boolean values for plotting multiple series. Defaults to `False`.\n* `title` - The title of the plot. Defaults to `None`.\n* `width` - The width of the plotting region, in characters. Default is `60`.\n  Note that if the `line_length_hard_cap` option (see \"Advanced options\" below)\n  is used and there is not enough space, the actual width may be smaller.\n* `x_max` - Maximum x value of the view. Defaults to a value that shows all\n  data points.\n* `x_min` - Minimum x value of the view. Defaults to a value that shows all\n  data points.\n* `x_unit` - Unit of the x axis. This is a string that is appended to the axis\n  labels. Defaults to `\"\"`.\n* `y_max` - Maximum y value of the view. Defaults to a value that shows all\n  data points.\n* `y_min` - Minimum y value of the view. Defaults to a value that shows all\n  data points.\n* `y_unit` - Unit of the y axis. This is a string that is appended to the axis\n  labels. Defaults to `\"\"`.\n\n#### Advanced options\n\n* `character_set` - Which Unicode character set to use. Use `\"block\"` for\n  the [Block Elements character\n  set](https://en.wikipedia.org/wiki/Block_Elements) with 4x resolution, or\n  `\"braille\"` for the [Braille character\n  set](https://en.wikipedia.org/wiki/Braille_Patterns) with 8x resolution,\n  `\"ascii\"` to use ASCII characters only. Braille has the highest resolution,\n  and a lighter look overall. Defaults to `\"block\"`.\n* `force_ascii_characters` -  List of characters to use when using the\n  ASCII character set. Defaults to `[\"+\", \"x\", \"o\", \"*\", \"~\", \".\"]`.\n* `legend_placement` - Arrangement of the legend labels. `\"auto\"` attempts to\n  place them one or more rows next to each other, while `\"vertical\"` is a\n  block with one label per row. Defaults to `\"auto\"`.\n* `line_length_hard_cap` - Enforce a hard limit on the number of characters per\n  line of the plot area. This may override the `width` option if there is not\n  enough space. Defaults to `None`.\n* `rounded_corners` - Draw bounding box with round corners. Defaults to `False.\n* `x_as_log` - Plot the x axis as logarithmic scale. Defaults to `False`.\n* `x_gridlines` - A list of x values that have a vertical line for better\n  orientation. Defaults to `[0]`, or to `[]` if `x_as_log` is enabled.\n* `x_gridlines_color` - A boolean or a list of colors for the vertical\n  gridlines, as specified above for the `color` option. Defaults to `False`.\n* `x_labels` - Enable axis labels for the x axis. Defaults to `True`.\n* `y_as_log` - Plot the y axis as logarithmic scale. Defaults to `False`.\n* `y_gridlines` - A list of y values that have a horizontal line for better\n  orientation. Defaults to `[0]`, or to `[]` if `y_as_log` is enabled.\n* `y_gridlines_color` - A boolean or a list of colors for the horizontal\n  gridlines, as specified above for the `color` option. Defaults to `False`.\n* `y_labels` - Enable axis labels for the y axis. Defaults to `True`.\n\n\n### Changing default parameters\n\nuniplot does not store a state of the configuration parameters. However, you\ncan define a new plot funtion with new defaults by defining a `partial`. See\nthe following example:\n\n```python\nfrom functools import partial\nfrom uniplot import plot as default_plot\nplot = partial(default_plot, height=25, width=80)\n```\n\nThis defines a new `plot` function that is identical to the original, except\nthe default values for `width` and `height` are now different.\n\n\n## Experimental features\n\n### Plotting histograms\n\nFor convenience there is also a `histogram` function that accepts one or more\nseries and plots bar-chart like histograms. It will automatically discretize\nthe series into a number of bins given by the `bins` option and display the\nresult.\n\nAdditional options, in alphabetical order:\n\n* `bins` - Number of bins to use. Defaults to `20`.\n* `bins_min` - Lower limit of the first bin. Defaults to the minimum of the\n  series.\n* `bins_max` - Upper limit of the last bin. Defaults to the maximum of the\n  series.\n\nWhen calling the `histogram` function, the `lines` option is `True` by default.\n\nExample:\n\n```python\nimport numpy as np\nx = np.sin(np.linspace(1, 1000))\nfrom uniplot import histogram\nhistogram(x)\n```\n\nResult:\n```\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502   \u259b\u2580\u2580\u258c                       \u2502                   \u2590\u2580\u2580\u259c      \u2502 5\n\u2502   \u258c  \u258c                       \u2502                   \u2590  \u2590      \u2502\n\u2502   \u258c  \u258c                       \u2502                   \u2590  \u2590      \u2502\n\u2502   \u258c  \u2580\u2580\u2580\u258c                    \u2502                \u2590\u2580\u2580\u2580  \u259d\u2580\u2580\u259c   \u2502\n\u2502   \u258c     \u258c                    \u2502                \u2590        \u2590   \u2502\n\u2502   \u258c     \u258c                    \u2502                \u2590        \u2590   \u2502\n\u2502   \u258c     \u2599\u2584\u2584\u2584\u2584\u2584\u2596              \u2502          \u2597\u2584\u2584\u2584  \u2590        \u2590   \u2502\n\u2502   \u258c           \u258c              \u2502          \u2590  \u2590  \u2590        \u2590   \u2502\n\u2502   \u258c           \u258c              \u2502          \u2590  \u2590  \u2590        \u2590   \u2502\n\u2502   \u258c           \u258c              \u2502          \u2590  \u2590  \u2590        \u2590   \u2502\n\u2502   \u258c           \u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u259c  \u2590\u2580\u2580\u2580  \u259d\u2580\u2580\u2580        \u2590   \u2502\n\u2502   \u258c                          \u2502    \u2590  \u2590                 \u2590   \u2502\n\u2502   \u258c                          \u2502    \u2590  \u2590                 \u2590   \u2502\n\u2502   \u258c                          \u2502    \u2590\u2584\u2584\u259f                 \u2590   \u2502\n\u2502   \u258c                          \u2502                         \u2590   \u2502\n\u2502   \u258c                          \u2502                         \u2590   \u2502\n\u2502\u2584\u2584\u2584\u258c\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2502\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2590\u2584\u2584\u2584\u2502 0\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n     -1                        0                       1\n```\n\n### Arrow keys and FPS-style keys\n\nIn interactive mode, we now also support wasd or FPS-style keyboard layout and\nthe arrow keys. Arrows should work on most platforms like Mac, Linux or Windows. We might make the keyboard layout fully configurable, to change the current Vim-inspired one, at a later date. For now, you have 3 ways to move the view:\n\n* Vim-style: `h` left, `j` down, `k` up, `l` right, `u` zoom in, `n` zoom out.\n* FPS-style: `a` left, `s` down, `w` up, `d` right, `]` zoom in, `[` zoom out.\n* Arrow keys: movement obvious, `]` zoom in, `[` zoom out.\n\n\n### Streaming\n\nThere is initial support for streaming using the `plot_gen` function. The idea\nis have a class that wraps the plot function and the state of plotting, such\nthat we can `update` the state of the plot.\n\nExample, assuming we had a function called `get_new_data` to get new data from\nsome source:\n```python3\nfrom uniplot import plot_gen\n\nplt = plot_gen()\nys = []\n\nwhile True:\n    ys.append(get_new_data())\n    plt.update(ys=ys, title=f\"Streaming: {len(ys)} data point(s) ...\")\n```\n\nSee `examples/5-streaming.py` for a more complete example.\n\n\n## Installation\n\nInstall via pip using:\n\n```shell\npip install uniplot\n```\n\n\n## Contributing\n\nClone this repository, and make sure you\n[have uv installed](https://docs.astral.sh/uv/getting-started/installation/).\n\nOn most Linux-like systems like MacOS you can run:\n```shell\nmake\n```\nSee the `Makefile` for details and more granular commands.\n\nAlternatively, on systems like Windows that do not have `make` installed, you can run:\n```shell\nuv run scripts/run_tests.sh\n```\n\nThen proceed with issues, PRs etc. the usual way.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2020 Olav Stetter  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Lightweight plotting to the terminal. 4x resolution via Unicode.",
    "version": "0.21.4",
    "project_urls": {
        "Homepage": "https://github.com/olavolav/uniplot",
        "Issues": "https://github.com/olavolav/uniplot/issues",
        "Repository": "https://github.com/olavolav/uniplot"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4d565ddd9227373e56a70cb4d52f25a06656bfa9eaedbd39fe9f39537a689534",
                "md5": "21fb434452ae63e0ad8083465f448722",
                "sha256": "87d750afc5904ef0e2fe06e701f4424db602c4a2e996124be4a56b0dfba8e609"
            },
            "downloads": -1,
            "filename": "uniplot-0.21.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "21fb434452ae63e0ad8083465f448722",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 36714,
            "upload_time": "2025-08-03T07:43:28",
            "upload_time_iso_8601": "2025-08-03T07:43:28.273767Z",
            "url": "https://files.pythonhosted.org/packages/4d/56/5ddd9227373e56a70cb4d52f25a06656bfa9eaedbd39fe9f39537a689534/uniplot-0.21.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "71cc9ecf0d50960384d1dd818fb31d8a6b3ad62848fb0d29cd9c8b6345b90122",
                "md5": "b2b7f0bf03856ff8a99266d39712c0fc",
                "sha256": "8fc5a8e3ecb98f3cb74e9363715ea61658d5cfc4fb046b55a5f1a0ad658d4846"
            },
            "downloads": -1,
            "filename": "uniplot-0.21.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b2b7f0bf03856ff8a99266d39712c0fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 34031,
            "upload_time": "2025-08-03T07:43:29",
            "upload_time_iso_8601": "2025-08-03T07:43:29.686457Z",
            "url": "https://files.pythonhosted.org/packages/71/cc/9ecf0d50960384d1dd818fb31d8a6b3ad62848fb0d29cd9c8b6345b90122/uniplot-0.21.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-03 07:43:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "olavolav",
    "github_project": "uniplot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "uniplot"
}
        
Elapsed time: 1.62041s