Skip to content

Commit

Permalink
A gnuplot example.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Jun 26, 2024
1 parent 32fa351 commit d09a74f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ for plotting or rendering graphics.
- [Generating videos with literate Futhark](examples/literate-video.html)
- [Reading and writing files in literate Futhark](examples/literate-files.html)

# Plotting

Literate Futhark allows direct use of
[gnuplot](http://www.gnuplot.info/). These examples show simple and
common cases.

- [Plotting a histogram](examples/plot-histogram.html)

# Examples from Dex

The following examples are ported from
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions examples/plot-histogram.fut
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- # Plotting a histogram

-- This can be done by computing a histogram in Futhark and then using
-- a box plot. Here we produce some arbitrary values, discretised aong
-- *k* bins.

def plot k n : ([]i64,[]i32) =
let vs = iota n |> map (f64.i64 >-> f64.cos >-> (+1) >-> (*(f64.i64 k/2)) >-> i64.f64)
in (iota k,
hist (+) 0 k vs (replicate n 1))

-- > :gnuplot {data=plot 100 10000};
-- set xrange [0:100];
-- set style fill solid 1.0
-- plot data with boxes


-- ## See also
--
-- [Gnuplots built-in support for histograms](http://gnuplot.info/docs_6.1/loc5256.html).
--
-- [Generalised histograms.](histogram.html).

0 comments on commit d09a74f

Please sign in to comment.