plot-gtk-ui

A quick way to use Mathematica like Manipulation abilities

https://github.com/sumitsahrawat/plot-gtk-ui

Version on this page:0.3.0.0
LTS Haskell 9.21:0.3.0.2
Stackage Nightly 2017-07-25:0.3.0.2
Latest on Hackage:0.3.0.2

See all snapshots plot-gtk-ui appears in

GPL-2.0-only licensed by Sumit Sahrawat
Maintained by [email protected]
This version can be pinned in stack with:plot-gtk-ui-0.3.0.0@sha256:23d5133ad11162c9218f534e3e2ee3af39f385db7656c4f725840796fe66e143,2248

Module documentation for 0.3.0.0

Used by 1 package in nightly-2015-10-07(full list with versions):

plot-gtk-ui

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

Installation

stack install plot-gtk-ui

Usage

The best way to try this is to use the calculator package.

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

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

Another simple example.

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

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 “Gray screen of no 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 package.