What do you use to plot a list of (x,y) coordinates

I guess I should use Owl, but all I find in the plot documentation of Owl are functions that take functions and not a list of points as argument. A function that takes a x and a y list as the pythonic matplotlib.pyplot.plot would work too.

1 Like

Under Plot Figures — Owl Numerical Library 0.3 documentation, there’s an example of a use of Plot that takes a matrix of x and y points as input:

let x = Mat.linspace 0. 2. 100 in
let y0 = Mat.sigmoid x in
let y1 = Mat.map Maths.sin x in
let h = Plot.create "" in
Plot.(plot ~h ~spec:[ RGB (255,0,0); LineStyle 1; Marker "#[0x2299]"; MarkerSize 8. ] x y0);
Plot.(plot ~h ~spec:[ RGB (0,255,0); LineStyle 2; Marker "#[0x0394]"; MarkerSize 8. ] x y1);
Plot.(legend_on h ~position:SouthEast [|"sigmoid"; "sine"|]);
Plot.output h;;

So I guess you can use that if you convert your list of points to a matrix.

4 Likes

There is also archimedes.

1 Like

@fccm where can I find the documentation ?

https://docs.ocaml.pro/docs/OPAM.archimedes.0.4.19/

1 Like

I also found this example | notebook.community

1 Like

If you want something catchy to embed into an html page you can also use open-flash-chart.

There was an old binding for the Flash version of this lib in the past which is dead now because of Flash, but the json exchange format is maybe still the same.

You can also use oplot Oplot (oplot.Oplot)
For instance, in a toplevel

#require "oplot";;
open Oplot;;
let a = Plt.axis 0. 0.;;
let view = Plt.view 0. 0. 2. 1.;;
let sh = Plt.dot_plot ~view ~dot:Plt.diamond [(0.,1.); (1.,0.1); (0.5, 0.3); (2.,0.5)];;
Plt.display (List.append sh [Plt.(Color black); a]);;

This will plot your points as “diamonds”.
(the axis and the view are not obligatory)

2 Likes

gnuplot, what else? :wink:

People with less taste might use a wrapper for it; such as:

4 Likes