packages feed

plot-gtk-ui-0.0.1.0: README.md

# plot-gtk-ui

An ambitious attempt to provide mathematica like dynamic plotting for free.

## Installation

### Linux

The installation for gtk requires that
[gtk2hs-buildtools](https://hackage.haskell.org/package/gtk2hs-buildtools)
be installed, and the binary be in your $PATH.  The below commands take
care of that, without permanently changing the $PATH.

```bash
$ cabal update
$ cabal install gtk2hs-buildtools
$ env PATH="~/.cabal/bin:$PATH" cabal install plot-gtk-ui
```

### Windows

* Install gtk2hs with instructions from
  [here](http://projects.haskell.org/gtk2hs/download/#Windows).

* Then use cabal to install `plot-gtk-ui`.

```batch
cmd> cabal install plot-gtk-ui
```

## Usage

Import `Graphics.Rendering.Plot.Gtk.UI` and follow the examples below. 

```haskell
import Graphics.UI.Gtk
import Graphics.Rendering.Plot.Gtk.UI

main = do
  initGUI
  plotStatic sin (-pi, pi)
  -- Plot sin(x) from -pi to pi
  mainGUI
```

![sinx](screenshots/sinx.png)

Another simple example.

```haskell
import Graphics.UI.Gtk
import Graphics.Rendering.Plot.Gtk.UI

main = do
  initGUI
  plotDynamic (\(x, a) -> sin(a * x)) ((-pi, pi), (0, 1))
  -- Plot sin(a * x), where 'x' ranges from -pi to
  -- pi and 'a' ranges between 0 to 1
  mainGUI
```

![sinax](screenshots/sinax.png)

## Errors

The error messages might not be completely correct, as there is not a good way to diagnose what caused the error.

Issues that cause errors:

- Invalid ranges, e.g. X-Range = `(1, -1)`
- Automatic-determination of ranges resulting in unplottable ranges, e.g. `(0, 0)`

If you land on the "grey screen of on plots" or any other incorrect error message, please raise an issue here.

## Implementation

The `plotStatic` and `plotDynamic` functions are implemented in a
type-safe manner using `fixed-vector`.

It also allows one to write functions using appropriate tuples as in the
above examples.

Plotting is done using the excellent [plot](https://github.com/amcphail/plot)
package.