Plot coordinate pairs: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: IupCloseOnEscape no longer needed)
Line 1,875: Line 1,875:
[http://img28.picoodle.com/img/img28/4/2/7/f_qsortrange1m_1b7f493.png qsort-range-10-9.png]
[http://img28.picoodle.com/img/img28/4/2/7/f_qsortrange1m_1b7f493.png qsort-range-10-9.png]

=={{header|Nim}}==
===Using gnuplot===
{{libheader|gnuplot.nim}}
There exists two libraries providing a Nim interface to “gnuplot” (the GNU plotting program), which are named “gnuplot” and “gnuplotlib”. We have chosen the first one here but the second which is newer seems also to be more complete.

The library launches “gnuplot” which does the plotting. From “gnuplot”, it is possible to save the drawing into a PDF, a SVG or an image (BMP, PNG) file.

<lang Nim>import gnuplot

let
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]

plot(x, y, "Coordinate pairs")
discard stdin.readChar # Needed as when the program exits, “gnuplot” is closed.</lang>

===Using ggplotnim===
{{libheader|ggplotnim}}
This library doesn’t use an external process to does the plotting. It uses a syntax mostly compliant with “ggplot2” syntax.
<lang Nim>import ggplotnim

let
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]

let df = seqsToDf(x, y) # Build a dataframe.

df.ggplot(aes("x", "y")) +
ggtitle("Coordinate pairs") +
geomLine() +
themeOpaque() +
ggsave("coordinate_pairs.png")</lang>


=={{header|OCaml}}==
=={{header|OCaml}}==