Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "plplot"

Title:A library to plot data using gnuplot.
Rating:Not rated. Create the first rating!
Latest version:0.0.1
SHA1 sum:1aaa8b9303232c6d7962e719b7f2a61728250e97
Author:Damiano Azzolini <damiano.azzolini@unife.it>
Download URL:https://github.com/damianoazzolini/plplot.git

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.0.11aaa8b9303232c6d7962e719b7f2a61728250e971https://github.com/damianoazzolini/plplot.git

plplot

Plot graphs using prolog and gnuplot.

Requirements

gnuplot must be installed and in the path.

To check if gnuplot is installed type: `command -v gnuplot`. If nothing is printed, this means that gnuplot is missing.

You can download it from http://www.gnuplot.info/download.html and then follow the instructions in the folder.

Usually you need other libraries to install gnuplot as libwxgtk3.0-dev libpango1.0-dev and libreadline5-dev.

Installation

plplot can be installed using pack_install/1

$ swipl
?- pack_install(plplot).

Still does not work on Windows

Example

$ swipl ?- use_module(library(plplot)). ?- plot_point('Title',[1.0, 2.0, 3.0, 4.0, 5.0],[5.0 ,3.0, 1.0, 3.0, 5.0]).

The result should be something like: !Screenshot

Available Predicates

  • plot_point/3: plots the points.
  • plot_line/3: plots the points and connect them with lines.

How it works

It's simple: the commands are saved in a file named commands.txt. The data are saved in a file named data.temp. Then gnuplot is called passing those two files.

How to test without using pack_install/1

To use the program without downloading the package with pack_install/1 you can do:

  • Find the file `<SWI-Prolog.h>`. Usually is `/usr/local/lib/swipl/include/ or /usr/lib/swi-prolog/include/`.
  • Generate the `.o` file with gcc passing the location of `<SWI-Prolog.h>`. If it's in `/usr/local/lib/swipl/include/` then the command is:
    • `gcc -I/usr/local/lib/swipl/include/ -fpic -c plplot.c`
  • Generate the `.so` file with:
    • `gcc -shared -o plplot.so plplot.o`
  • Now you can create a file test.pl like this:
    :- load_foreign_library(plplot).
    
    test_p:-
        plot_point('Title',[1.0, 2.0, 3.0, 4.0, 5.0],[5.0 ,3.0, 1.0, 3.0, 5.0]).
    
  • To test use:
        $ swipl test.pl
    
        ?- test_p.

Contribute and suggestions

Pull requests, issues or whatever you prefer.

Contents of pack "plplot"

Pack contains 11 files holding a total of 44.0K bytes.