Plot coordinate pairs: Difference between revisions
Content added Content deleted
(Added Processing implementation) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 13: | Line 13: | ||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
||
<syntaxhighlight lang="aarch64 assembly"> |
|||
<lang AArch64 Assembly> |
|||
/* ARM assembly AARCH64 Raspberry PI 3B */ |
/* ARM assembly AARCH64 Raspberry PI 3B */ |
||
/* program areaPlot64.s */ |
/* program areaPlot64.s */ |
||
Line 295: | Line 295: | ||
.include "../includeARM64.inc" |
.include "../includeARM64.inc" |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Output}} |
{{Output}} |
||
<pre> |
<pre> |
||
Line 326: | Line 326: | ||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
{{libheader|Action! Tool Kit}} |
{{libheader|Action! Tool Kit}} |
||
< |
<syntaxhighlight lang="action!">INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit |
||
DEFINE PTR="CARD" |
DEFINE PTR="CARD" |
||
Line 517: | Line 517: | ||
DO UNTIL CH#$FF OD |
DO UNTIL CH#$FF OD |
||
CH=$FF |
CH=$FF |
||
RETURN</ |
RETURN</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Plot_coordinate_pairs.png Screenshot from Atari 8-bit computer] |
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Plot_coordinate_pairs.png Screenshot from Atari 8-bit computer] |
||
Line 526: | Line 526: | ||
{{libheader|GtkAda}} |
{{libheader|GtkAda}} |
||
[[Image:Gtkada_plot.png|thumb|right|100px|Example GtkAda plot]] |
[[Image:Gtkada_plot.png|thumb|right|100px|Example GtkAda plot]] |
||
< |
<syntaxhighlight lang="ada"> |
||
with Gtk.Main; |
with Gtk.Main; |
||
with Gtk.Window; use Gtk.Window; |
with Gtk.Window; use Gtk.Window; |
||
Line 573: | Line 573: | ||
Gtk.Main.Main; |
Gtk.Main.Main; |
||
end PlotCoords; |
end PlotCoords; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
Line 580: | Line 580: | ||
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}} |
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}} |
||
[[Image:Plot_coordinate_pairs-Algol68.gif|thumb|right|100px|Example Algol68 plot]] |
[[Image:Plot_coordinate_pairs-Algol68.gif|thumb|right|100px|Example Algol68 plot]] |
||
'''File: Plot_coordinate_pairs.a68'''< |
'''File: Plot_coordinate_pairs.a68'''<syntaxhighlight lang="algol68">#!/usr/bin/algol68g-full --script # |
||
# -*- coding: utf-8 -*- # |
# -*- coding: utf-8 -*- # |
||
Line 616: | Line 616: | ||
); |
); |
||
PR READ "postlude/exception.a68" PR</ |
PR READ "postlude/exception.a68" PR</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
Line 622: | Line 622: | ||
{{works with|AutoHotkey_L}}(AutoHotkey1.1+) |
{{works with|AutoHotkey_L}}(AutoHotkey1.1+) |
||
{{libheader|GDIP}} |
{{libheader|GDIP}} |
||
< |
<syntaxhighlight lang="autohotkey">#SingleInstance, Force |
||
#NoEnv |
#NoEnv |
||
SetBatchLines, -1 |
SetBatchLines, -1 |
||
Line 690: | Line 690: | ||
Exit: |
Exit: |
||
Gdip_Shutdown(pToken) |
Gdip_Shutdown(pToken) |
||
ExitApp</ |
ExitApp</syntaxhighlight> |
||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |
||
{{works with|BBC BASIC for Windows}} |
{{works with|BBC BASIC for Windows}} |
||
[[Image:Coordinate_pair_bbc.gif|right]] |
[[Image:Coordinate_pair_bbc.gif|right]] |
||
< |
<syntaxhighlight lang="bbcbasic"> DIM x(9), y(9) |
||
x() = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
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 |
y() = 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 |
||
Line 723: | Line 723: | ||
DRAW 100*x(i%),4*y(i%) |
DRAW 100*x(i%),4*y(i%) |
||
ENDIF |
ENDIF |
||
NEXT</ |
NEXT</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
Line 730: | Line 730: | ||
{{libheader|libplot}} |
{{libheader|libplot}} |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
#include <stdlib.h> |
#include <stdlib.h> |
||
#include <math.h> |
#include <math.h> |
||
Line 846: | Line 846: | ||
pl_flushpl(); |
pl_flushpl(); |
||
pl_closepl(); |
pl_closepl(); |
||
}</ |
}</syntaxhighlight> |
||
No one would use the previous code to produce a plot (that looks [http://i40.tinypic.com/f2t0l0.png this way]; instead, normally we produce data through a program, then we plot the data using e.g. [[Plot x, y arrays#gnuplot|gnuplot]] or other powerful tools; the result (with gnuplot and without enhancement) could look [http://i41.tinypic.com/2qivbsn.png like this] instead. |
No one would use the previous code to produce a plot (that looks [http://i40.tinypic.com/f2t0l0.png this way]; instead, normally we produce data through a program, then we plot the data using e.g. [[Plot x, y arrays#gnuplot|gnuplot]] or other powerful tools; the result (with gnuplot and without enhancement) could look [http://i41.tinypic.com/2qivbsn.png like this] instead. |
||
Line 852: | Line 852: | ||
===Writing EPS=== |
===Writing EPS=== |
||
[[File:plot-2d-c.png|center]]Following code creates a plot in EPS format, with auto scaling and line/symbol/color controls. Plotting function loosely follows Matlab command style. Not thorough by any means, just to give an idea on how this kind of things can be coded. |
[[File:plot-2d-c.png|center]]Following code creates a plot in EPS format, with auto scaling and line/symbol/color controls. Plotting function loosely follows Matlab command style. Not thorough by any means, just to give an idea on how this kind of things can be coded. |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
#include <math.h> |
#include <math.h> |
||
#include <string.h> |
#include <string.h> |
||
Line 982: | Line 982: | ||
plot(x, y, N, "r-o"); |
plot(x, y, N, "r-o"); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
[[File:plot_cpp.png|300px]] |
[[File:plot_cpp.png|300px]] |
||
< |
<syntaxhighlight lang="cpp"> |
||
#include <windows.h> |
#include <windows.h> |
||
#include <string> |
#include <string> |
||
Line 1,210: | Line 1,210: | ||
} |
} |
||
//-------------------------------------------------------------------------------------------------- |
//-------------------------------------------------------------------------------------------------- |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
{{libheader|incanter}} |
{{libheader|incanter}} |
||
< |
<syntaxhighlight lang="clojure">(use '(incanter core stats charts)) |
||
(def x (range 0 10)) |
(def x (range 0 10)) |
||
(def y '(2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0)) |
(def y '(2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0)) |
||
(view (xy-plot x y)) |
(view (xy-plot x y)) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{Out}} |
{{Out}} |
||
Line 1,227: | Line 1,227: | ||
{{Trans|Go}} |
{{Trans|Go}} |
||
Boost.Process is part of [https://github.com/MaiconSoft/DelphiBoostLib DelphiBoostLib]. |
Boost.Process is part of [https://github.com/MaiconSoft/DelphiBoostLib DelphiBoostLib]. |
||
<syntaxhighlight lang="delphi"> |
|||
<lang Delphi> |
|||
program Plot_coordinate_pairs; |
program Plot_coordinate_pairs; |
||
Line 1,255: | Line 1,255: | ||
plot.Free; |
plot.Free; |
||
readln; |
readln; |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
[https://easylang.online/apps/_plot_coord.html Run it] |
[https://easylang.online/apps/_plot_coord.html Run it] |
||
<lang>x[] = [ 0 1 2 3 4 5 6 7 8 9 ] |
<syntaxhighlight lang="text">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 ] |
y[] = [ 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 ] |
||
# |
# |
||
Line 1,298: | Line 1,298: | ||
line x y |
line x y |
||
. |
. |
||
.</ |
.</syntaxhighlight> |
||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |
||
Resulting image [http://www.echolalie.org/echolisp/images/plot-coordinates.png here]. |
Resulting image [http://www.echolalie.org/echolisp/images/plot-coordinates.png here]. |
||
< |
<syntaxhighlight lang="scheme"> |
||
(lib 'plot) |
(lib 'plot) |
||
Line 1,312: | Line 1,312: | ||
(plot-grid 1 20) |
(plot-grid 1 20) |
||
(plot-text " Rosetta plot coordinate pairs" 0 10 "white") |
(plot-text " Rosetta plot coordinate pairs" 0 10 "white") |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
Using [https://github.com/psyeugenic/eplot Eplot] to produce PNG. |
Using [https://github.com/psyeugenic/eplot Eplot] to produce PNG. |
||
<syntaxhighlight lang="erlang"> |
|||
<lang Erlang> |
|||
-module( plot_coordinate_pairs ). |
-module( plot_coordinate_pairs ). |
||
Line 1,330: | Line 1,330: | ||
PNG = egd_chart:graph( [{File, lists:zip(Xs, Ys)}] ), |
PNG = egd_chart:graph( [{File, lists:zip(Xs, Ys)}] ), |
||
file:write_file( File ++ ".png", PNG ). |
file:write_file( File ++ ".png", PNG ). |
||
</syntaxhighlight> |
|||
</lang> |
|||
The result looks like [https://github.com/ebengt/rosettacode/blob/master/graphs/plot_coordinate_pairs.png this]. |
The result looks like [https://github.com/ebengt/rosettacode/blob/master/graphs/plot_coordinate_pairs.png this]. |
||
Line 1,337: | Line 1,337: | ||
Using the [http://www.ffconsultancy.com/products/fsharp_for_visualization/ F# for Visualization] library: |
Using the [http://www.ffconsultancy.com/products/fsharp_for_visualization/ F# for Visualization] library: |
||
[[Image:FSViz.png|300px|thumb|right|alt text]] |
[[Image:FSViz.png|300px|thumb|right|alt text]] |
||
< |
<syntaxhighlight lang="fsharp">#r @"C:\Program Files\FlyingFrog\FSharpForVisualization.dll" |
||
let x = Seq.map float [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9|] |
let x = Seq.map float [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9|] |
||
Line 1,344: | Line 1,344: | ||
open FlyingFrog.Graphics |
open FlyingFrog.Graphics |
||
Plot([Data(Seq.zip x y)], (0.0, 9.0))</ |
Plot([Data(Seq.zip x y)], (0.0, 9.0))</syntaxhighlight> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2019-01-23}} |
{{works with|Factor|0.99 2019-01-23}} |
||
< |
<syntaxhighlight lang="factor">USING: accessors assocs colors.constants kernel sequences ui |
||
ui.gadgets ui.gadgets.charts ui.gadgets.charts.lines ; |
ui.gadgets ui.gadgets.charts ui.gadgets.charts.lines ; |
||
Line 1,354: | Line 1,354: | ||
line new COLOR: blue >>color |
line new COLOR: blue >>color |
||
9 <iota> { 2.7 2.8 31.4 38.1 58 76.2 100.5 130 149.3 180 } zip |
9 <iota> { 2.7 2.8 31.4 38.1 58 76.2 100.5 130 149.3 180 } zip |
||
>>data add-gadget "Coordinate pairs" open-window</ |
>>data add-gadget "Coordinate pairs" open-window</syntaxhighlight> |
||
=={{header|Fōrmulæ}}== |
=={{header|Fōrmulæ}}== |
||
Line 1,367: | Line 1,367: | ||
{{trans|Liberty BASIC}} |
{{trans|Liberty BASIC}} |
||
===Text mode=== |
===Text mode=== |
||
< |
<syntaxhighlight lang="freebasic">Dim As Integer i, x(9), y(9) |
||
For i = 0 To 9 |
For i = 0 To 9 |
||
x(i) = i |
x(i) = i |
||
Line 1,396: | Line 1,396: | ||
Locate (21 - (y(i)/ 10)), (x(i) * 4) + 2 : Print "." |
Locate (21 - (y(i)/ 10)), (x(i) * 4) + 2 : Print "." |
||
Next i |
Next i |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
=={{header|gnuplot}}== |
=={{header|gnuplot}}== |
||
[[Image:Plotxy-gnuplot.png|thumb|right|200px|Example gnuplot output]] |
[[Image:Plotxy-gnuplot.png|thumb|right|200px|Example gnuplot output]] |
||
< |
<syntaxhighlight lang="gnuplot">unset key # Only one data set, so the key is uninformative |
||
plot '-' # '-' can be replaced with a filename, to read data from that file. |
plot '-' # '-' can be replaced with a filename, to read data from that file. |
||
Line 1,414: | Line 1,414: | ||
8 149.3 |
8 149.3 |
||
9 180.0 |
9 180.0 |
||
e</ |
e</syntaxhighlight> |
||
<br clear=right> |
<br clear=right> |
||
Line 1,423: | Line 1,423: | ||
A program can of course supply commands and data to gnuplot as prepared files. For the spirit of controlling plotting with the native language however, this example shows how commands and data can be prepared programatically and supplied to gnuplot through stdin. |
A program can of course supply commands and data to gnuplot as prepared files. For the spirit of controlling plotting with the native language however, this example shows how commands and data can be prepared programatically and supplied to gnuplot through stdin. |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 1,452: | Line 1,452: | ||
w.Close() |
w.Close() |
||
g.Wait() |
g.Wait() |
||
}</ |
}</syntaxhighlight> |
||
===gonum/plot=== |
===gonum/plot=== |
||
{{libheader|gonum/plot}} |
{{libheader|gonum/plot}} |
||
[[File:GoPoints.png|right|Go plot]] |
[[File:GoPoints.png|right|Go plot]] |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 1,487: | Line 1,487: | ||
log.Fatal(err) |
log.Fatal(err) |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
Line 1,493: | Line 1,493: | ||
[[File:GroovyPlotDemo.png|300px|thumb|right|Screenshot of groovy solution]] |
[[File:GroovyPlotDemo.png|300px|thumb|right|Screenshot of groovy solution]] |
||
< |
<syntaxhighlight lang="groovy">import groovy.swing.SwingBuilder |
||
import javax.swing.JFrame |
import javax.swing.JFrame |
||
import org.jfree.chart.ChartFactory |
import org.jfree.chart.ChartFactory |
||
Line 1,520: | Line 1,520: | ||
widget(chart()) |
widget(chart()) |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
gnuplot is a package from [http://hackage.haskell.org/packages/hackage.html HackageDB]. |
gnuplot is a package from [http://hackage.haskell.org/packages/hackage.html HackageDB]. |
||
< |
<syntaxhighlight lang="haskell">import Graphics.Gnuplot.Simple |
||
pnts = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] |
pnts = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] |
||
doPlot = plotPathStyle [ ( Title "plotting dots" )] |
doPlot = plotPathStyle [ ( Title "plotting dots" )] |
||
(PlotStyle Points (CustomStyle [])) (zip [0..] pnts)</ |
(PlotStyle Points (CustomStyle [])) (zip [0..] pnts)</syntaxhighlight> |
||
=={{header|HicEst}}== |
=={{header|HicEst}}== |
||
< |
<syntaxhighlight lang="hicest">REAL :: n=10, x(n), y(n) |
||
x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) |
x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) |
||
Line 1,539: | Line 1,539: | ||
WINDOW(WINdowhandle=wh, Width=-300, Height=-300, X=1, TItle='Rosetta') |
WINDOW(WINdowhandle=wh, Width=-300, Height=-300, X=1, TItle='Rosetta') |
||
AXIS(WINdowhandle=wh, Title='x values', Yaxis, Title='y values') |
AXIS(WINdowhandle=wh, Title='x values', Yaxis, Title='y values') |
||
LINE(X=x, Y=y, SymbolDiameter=2)</ |
LINE(X=x, Y=y, SymbolDiameter=2)</syntaxhighlight> |
||
[[File:HicEst_plot_coordinate_pairs.png]] |
[[File:HicEst_plot_coordinate_pairs.png]] |
||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
[[File:Plotpoints-unicon.gif|thumb|right|Sample Output]] |
[[File:Plotpoints-unicon.gif|thumb|right|Sample Output]] |
||
< |
<syntaxhighlight lang="icon">link printf,numbers |
||
procedure main() |
procedure main() |
||
Line 1,629: | Line 1,629: | ||
every q[i := 1 to *q] := pix - q[i] |
every q[i := 1 to *q] := pix - q[i] |
||
return P |
return P |
||
end</ |
end</syntaxhighlight> |
||
{{libheader|Icon Programming Library}} |
{{libheader|Icon Programming Library}} |
||
Line 1,637: | Line 1,637: | ||
=={{header|J}}== |
=={{header|J}}== |
||
{{libheader|plot}} |
{{libheader|plot}} |
||
< |
<syntaxhighlight lang="j">require 'plot' |
||
X=: i.10 |
X=: i.10 |
||
Y=: 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 |
Y=: 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 |
||
'dot; pensize 2.4' plot X;Y</ |
'dot; pensize 2.4' plot X;Y</syntaxhighlight> |
||
[http://www.jsoftware.com/jwiki/RosettaCode/ExamplePlot1 Output of plot.] |
[http://www.jsoftware.com/jwiki/RosettaCode/ExamplePlot1 Output of plot.] |
||
Line 1,648: | Line 1,648: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java"> import java.awt.*; |
||
import java.awt.event.*; |
import java.awt.event.*; |
||
import java.awt.geom.*; |
import java.awt.geom.*; |
||
Line 1,737: | Line 1,737: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|jq}}== |
=={{header|jq}}== |
||
Line 1,744: | Line 1,744: | ||
jq is designed to interoperate with other tools, and in this section we illustrate how jq can be used with R in a simple pipeline: jq will produce a stream of CSV data that will be piped into R operating in non-interactive mode. Assuming the jq and R programs are respectively in plot.jq and plot.R, the pipeline would look like this: |
jq is designed to interoperate with other tools, and in this section we illustrate how jq can be used with R in a simple pipeline: jq will produce a stream of CSV data that will be piped into R operating in non-interactive mode. Assuming the jq and R programs are respectively in plot.jq and plot.R, the pipeline would look like this: |
||
< |
<syntaxhighlight lang="sh">jq -n -M -r -f plot.jq | R CMD BATCH plot.R</syntaxhighlight> |
||
The above would produce the plot as a .pdf file. |
The above would produce the plot as a .pdf file. |
||
'''plot.jq''' |
'''plot.jq''' |
||
< |
<syntaxhighlight lang="jq"># NOTE: This definition of transpose can be omitted |
||
# if your version of jq includes transpose as a builtin. |
# if your version of jq includes transpose as a builtin. |
||
# |
# |
||
Line 1,767: | Line 1,767: | ||
def plot(x;y): "A,B", ( [x,y] | transpose | map( @csv ) | .[]); |
def plot(x;y): "A,B", ( [x,y] | transpose | map( @csv ) | .[]); |
||
plot(x;y)</ |
plot(x;y)</syntaxhighlight> |
||
'''plot.R''' |
'''plot.R''' |
||
< |
<syntaxhighlight lang="r">mydata <- read.table( file("stdin"), header=TRUE, sep=",") |
||
x = mydata$A # x-axis |
x = mydata$A # x-axis |
||
Line 1,776: | Line 1,776: | ||
main="Scatterplot Example", |
main="Scatterplot Example", |
||
xlab="x-axis label", # x-axis label |
xlab="x-axis label", # x-axis label |
||
ylab="y-axis label" ) # y-axis label</ |
ylab="y-axis label" ) # y-axis label</syntaxhighlight> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Using Plots library with PlotlyJS as backend: |
Using Plots library with PlotlyJS as backend: |
||
< |
<syntaxhighlight lang="julia">using Plots |
||
plotlyjs() |
plotlyjs() |
||
Line 1,788: | Line 1,788: | ||
p = scatter(x, y) |
p = scatter(x, y) |
||
savefig(p, "/tmp/testplot.png")</ |
savefig(p, "/tmp/testplot.png")</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{libheader|JFreeChart}} |
{{libheader|JFreeChart}} |
||
{{trans|Groovy}} |
{{trans|Groovy}} |
||
< |
<syntaxhighlight lang="scala">// Version 1.2.31 |
||
import org.jfree.chart.ChartFactory |
import org.jfree.chart.ChartFactory |
||
Line 1,831: | Line 1,831: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,839: | Line 1,839: | ||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
1) define X & Y: |
1) define X & Y: |
||
Line 1,876: | Line 1,876: | ||
4) the result can be seen in http://lambdaway.free.fr/lambdawalks/?view=plot4 |
4) the result can be seen in http://lambdaway.free.fr/lambdawalks/?view=plot4 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
First version writes directly to LB's console window. |
First version writes directly to LB's console window. |
||
<syntaxhighlight lang="lb"> |
|||
<lang lb> |
|||
'Plotting coordinate pairs MainWin - Style |
'Plotting coordinate pairs MainWin - Style |
||
For i = 0 To 9 |
For i = 0 To 9 |
||
Line 1,915: | Line 1,915: | ||
End |
End |
||
</syntaxhighlight> |
|||
</lang> |
|||
The second version uses the more typical graphic window approach, and is written to enable easy adaptation to other data sets. |
The second version uses the more typical graphic window approach, and is written to enable easy adaptation to other data sets. |
||
<syntaxhighlight lang="lb"> |
|||
<lang lb> |
|||
nomainwin |
nomainwin |
||
Line 1,981: | Line 1,981: | ||
sy = offsetY-y*scaleY 'y is inverted |
sy = offsetY-y*scaleY 'y is inverted |
||
end function |
end function |
||
</syntaxhighlight> |
|||
</lang> |
|||
[http://www.diga.me.uk/PlotCoordPairs.gif LB screen] |
[http://www.diga.me.uk/PlotCoordPairs.gif LB screen] |
||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
Displaying the plot with vector graphics |
Displaying the plot with vector graphics |
||
<syntaxhighlight lang="livecode"> |
|||
<lang liveCode> |
|||
on plotGraphic |
on plotGraphic |
||
local tCoordinates |
local tCoordinates |
||
Line 2,009: | Line 2,009: | ||
set the loc of grc "graph" to the loc of this card |
set the loc of grc "graph" to the loc of this card |
||
end plotGraphic |
end plotGraphic |
||
</syntaxhighlight> |
|||
</lang> |
|||
[https://www.mediafire.com/view/xhi8oq1fawagzbt Result with Vector Graphics] |
[https://www.mediafire.com/view/xhi8oq1fawagzbt Result with Vector Graphics] |
||
Displaying the plot with the Line Graph widget |
Displaying the plot with the Line Graph widget |
||
<syntaxhighlight lang="livecode"> |
|||
<lang liveCode> |
|||
on plotLineGraph |
on plotLineGraph |
||
local tCoordinates |
local tCoordinates |
||
Line 2,029: | Line 2,029: | ||
set the loc of widget "graph" to the loc of this card |
set the loc of widget "graph" to the loc of this card |
||
end plotLineGraph |
end plotLineGraph |
||
</syntaxhighlight> |
|||
</lang> |
|||
[https://www.mediafire.com/view/8wj0l5l5blmd9dg/line_graph.jpg Result with Line Graph Widget] |
[https://www.mediafire.com/view/8wj0l5l5blmd9dg/line_graph.jpg Result with Line Graph Widget] |
||
Line 2,035: | Line 2,035: | ||
{{libheader|LÖVE}} |
{{libheader|LÖVE}} |
||
< |
<syntaxhighlight lang="lua"> |
||
w_width = love.graphics.getWidth() |
w_width = love.graphics.getWidth() |
||
w_height = love.graphics.getHeight() |
w_height = love.graphics.getHeight() |
||
Line 2,081: | Line 2,081: | ||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Line 2,088: | Line 2,088: | ||
Result image [https://4.bp.blogspot.com/-8XdIVaW79lU/W_iCUBmj92I/AAAAAAAAHbA/TxMl_P22yckQ1Wdi4zsu6k_QVNRZpqJCgCLcBGAs/s1600/graph222.png here] |
Result image [https://4.bp.blogspot.com/-8XdIVaW79lU/W_iCUBmj92I/AAAAAAAAHbA/TxMl_P22yckQ1Wdi4zsu6k_QVNRZpqJCgCLcBGAs/s1600/graph222.png here] |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
Module Pairs { |
Module Pairs { |
||
\\ written in version 9.5 rev. 13 |
\\ written in version 9.5 rev. 13 |
||
Line 2,161: | Line 2,161: | ||
} |
} |
||
Pairs |
Pairs |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
< |
<syntaxhighlight lang="maple">x := Vector([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]): |
||
y := Vector([2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]): |
y := Vector([2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]): |
||
plot(x,y,style="point");</ |
plot(x,y,style="point");</syntaxhighlight> |
||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">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}; |
y={2.7,2.8,31.4,38.1,58.0,76.2,100.5,130.0,149.3,180.0}; |
||
ListPlot[{x, y} // Transpose]</ |
ListPlot[{x, y} // Transpose]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[http://i43.tinypic.com/2a689yw.png] |
[http://i43.tinypic.com/2a689yw.png] |
||
=={{header|MATLAB}}== |
=={{header|MATLAB}}== |
||
< |
<syntaxhighlight lang="matlab">>> 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]; |
>> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; |
||
>> plot(x,y,'.-')</ |
>> plot(x,y,'.-')</syntaxhighlight> |
||
=={{header|Maxima}}== |
=={{header|Maxima}}== |
||
< |
<syntaxhighlight lang="maxima">(%i1) ".." (m, n) := makelist (i, i, m, n); infix ("..")$ |
||
(%i2) x: 0 .. 9$ y:[2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]$ |
(%i2) x: 0 .. 9$ y:[2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]$ |
||
(%i3) plot2d(['discrete, x, y], [style, [points,5,1,1]], [gnuplot_term, png], [gnuplot_out_file, "qsort-range-10-9.png"])$</ |
(%i3) plot2d(['discrete, x, y], [style, [points,5,1,1]], [gnuplot_term, png], [gnuplot_out_file, "qsort-range-10-9.png"])$</syntaxhighlight> |
||
[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] |
||
Line 2,195: | Line 2,195: | ||
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. |
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. |
||
< |
<syntaxhighlight lang="nim">import gnuplot |
||
let |
let |
||
Line 2,202: | Line 2,202: | ||
plot(x, y, "Coordinate pairs") |
plot(x, y, "Coordinate pairs") |
||
discard stdin.readChar # Needed as when the program exits, “gnuplot” is closed.</ |
discard stdin.readChar # Needed as when the program exits, “gnuplot” is closed.</syntaxhighlight> |
||
===Using ggplotnim=== |
===Using ggplotnim=== |
||
{{libheader|ggplotnim}} |
{{libheader|ggplotnim}} |
||
This library doesn’t use an external process to does the plotting. It uses a syntax mostly compliant with “ggplot2” syntax. |
This library doesn’t use an external process to does the plotting. It uses a syntax mostly compliant with “ggplot2” syntax. |
||
< |
<syntaxhighlight lang="nim">import ggplotnim |
||
let |
let |
||
Line 2,219: | Line 2,219: | ||
geomLine() + |
geomLine() + |
||
themeOpaque() + |
themeOpaque() + |
||
ggsave("coordinate_pairs.png")</ |
ggsave("coordinate_pairs.png")</syntaxhighlight> |
||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">#load "graphics.cma" |
||
open Graphics |
open Graphics |
||
Line 2,241: | Line 2,241: | ||
ignore(wait_next_event [Key_pressed]); |
ignore(wait_next_event [Key_pressed]); |
||
close_graph(); |
close_graph(); |
||
;;</ |
;;</syntaxhighlight> |
||
Using the [http://forge.ocamlcore.org/projects/archimedes/ Archimedes] library, |
Using the [http://forge.ocamlcore.org/projects/archimedes/ Archimedes] library, |
||
one can write: |
one can write: |
||
[[Image:Archimedes.png|300px|thumb|right|Archimedes plot (graphics output).]] |
[[Image:Archimedes.png|300px|thumb|right|Archimedes plot (graphics output).]] |
||
< |
<syntaxhighlight lang="ocaml"> |
||
module A = Archimedes |
module A = Archimedes |
||
Line 2,257: | Line 2,257: | ||
A.Array.y vp y; |
A.Array.y vp y; |
||
A.close vp |
A.close vp |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
< |
<syntaxhighlight lang="octave">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]; |
y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; |
||
plot(x,y,"o"); |
plot(x,y,"o"); |
||
pause;</ |
pause;</syntaxhighlight> |
||
=={{header|Ol}}== |
=={{header|Ol}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
; define input arrays |
; define input arrays |
||
(define x '(0 1 2 3 4 5 6 7 8 9)) |
(define x '(0 1 2 3 4 5 6 7 8 9)) |
||
Line 2,281: | Line 2,281: | ||
(map glVertex2f x y) |
(map glVertex2f x y) |
||
(glEnd))) |
(glEnd))) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
<lang |
<syntaxhighlight lang="parigp">plothraw(vx, vy)</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
Line 2,291: | Line 2,291: | ||
{{libheader|GD::Graph}} |
{{libheader|GD::Graph}} |
||
< |
<syntaxhighlight lang="perl">use GD::Graph::points; |
||
@data = ( |
@data = ( |
||
Line 2,302: | Line 2,302: | ||
binmode $fh; |
binmode $fh; |
||
print $fh $graph->plot(\@data)->png; |
print $fh $graph->plot(\@data)->png; |
||
close $fh;</ |
close $fh;</syntaxhighlight> |
||
===Imager::Plot library=== |
===Imager::Plot library=== |
||
{{libheader|Imager::Plot}} |
{{libheader|Imager::Plot}} |
||
< |
<syntaxhighlight lang="perl">use Imager; |
||
use Imager::Plot; |
use Imager::Plot; |
||
Line 2,333: | Line 2,333: | ||
$img->box(filled => 1, color => 'white'); |
$img->box(filled => 1, color => 'white'); |
||
$plot->Render(Image => $img, Xoff => 50, Yoff => 350); |
$plot->Render(Image => $img, Xoff => 50, Yoff => 350); |
||
$img->write(file => 'qsort-range-10-9.png');</ |
$img->write(file => 'qsort-range-10-9.png');</syntaxhighlight> |
||
=={{header|Processing}}== |
=={{header|Processing}}== |
||
< |
<syntaxhighlight lang="java"> |
||
//Aamrun, 26th June 2022 |
//Aamrun, 26th June 2022 |
||
Line 2,351: | Line 2,351: | ||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{libheader|Phix/pGUI}} |
{{libheader|Phix/pGUI}} |
||
Output same as BBC BASIC, you can run this online [http://phix.x10.mx/p2js/Plot_coordinate_pairs.htm here]. |
Output same as BBC BASIC, you can run this online [http://phix.x10.mx/p2js/Plot_coordinate_pairs.htm here]. |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #000080;font-style:italic;">-- |
<span style="color: #000080;font-style:italic;">-- |
||
-- demo\rosetta\Plot_coordinate_pairs.exw |
-- demo\rosetta\Plot_coordinate_pairs.exw |
||
Line 2,381: | Line 2,381: | ||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
[[Image: Plotxy-picoLisp.png|thumb|right|200px|Example picoLisp output]] |
[[Image: Plotxy-picoLisp.png|thumb|right|200px|Example picoLisp output]] |
||
< |
<syntaxhighlight lang="picolisp">(load "@lib/ps.l") |
||
(scl 1) |
(scl 1) |
||
Line 2,419: | Line 2,419: | ||
(plot "plot.ps" 300 200 (2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0)) |
(plot "plot.ps" 300 200 (2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0)) |
||
(call 'display "plot.ps")</ |
(call 'display "plot.ps")</syntaxhighlight> |
||
=={{header|PostScript}}== |
=={{header|PostScript}}== |
||
<syntaxhighlight lang="postscript"> |
|||
<lang PostScript> |
|||
/x [0 1 2 3 4 5 6 7 8 9] def |
/x [0 1 2 3 4 5 6 7 8 9] def |
||
/y [2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0] def |
/y [2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0] def |
||
Line 2,434: | Line 2,434: | ||
}repeat |
}repeat |
||
stroke |
stroke |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
< |
<syntaxhighlight lang="purebasic">Structure PlotData |
||
x.i |
x.i |
||
y.f |
y.f |
||
Line 2,527: | Line 2,527: | ||
serie_y: |
serie_y: |
||
Data.f 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 |
Data.f 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 |
||
EndDataSection</ |
EndDataSection</syntaxhighlight> |
||
[[File:PureBasic PlotData.png]] |
[[File:PureBasic PlotData.png]] |
||
Line 2,537: | Line 2,537: | ||
Interactive session: |
Interactive session: |
||
< |
<syntaxhighlight lang="python">>>> 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] |
>>> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] |
||
Line 2,543: | Line 2,543: | ||
>>> pylab.plot(x, y, 'bo') |
>>> pylab.plot(x, y, 'bo') |
||
>>> pylab.savefig('qsort-range-10-9.png') |
>>> pylab.savefig('qsort-range-10-9.png') |
||
</syntaxhighlight> |
|||
</lang> |
|||
See some other examples: |
See some other examples: |
||
* [http://matplotlib.org/examples/pylab_examples/simple_plot.html simple plot] |
* [http://matplotlib.org/examples/pylab_examples/simple_plot.html simple plot] |
||
Line 2,550: | Line 2,550: | ||
==={{libheader|VPython}}=== |
==={{libheader|VPython}}=== |
||
< |
<syntaxhighlight lang="python"> |
||
from visual import * |
from visual import * |
||
from visual.graph import * |
from visual.graph import * |
||
Line 2,579: | Line 2,579: | ||
label(display=plot1.display, text="Look here", |
label(display=plot1.display, text="Look here", |
||
pos=(6,100.5), xoffset=30,yoffset=-20 ) |
pos=(6,100.5), xoffset=30,yoffset=-20 ) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|R}}== |
=={{header|R}}== |
||
R has several different plotting paradigms. First we define the data. |
R has several different plotting paradigms. First we define the data. |
||
< |
<syntaxhighlight lang="r">x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) |
||
y <- c(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0)</ |
y <- c(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0)</syntaxhighlight> |
||
===Base graphics=== |
===Base graphics=== |
||
<lang |
<syntaxhighlight lang="r">plot(x,y)</syntaxhighlight> |
||
===Lattice/grid graphics=== |
===Lattice/grid graphics=== |
||
{{libheader|lattice}} |
{{libheader|lattice}} |
||
< |
<syntaxhighlight lang="r">library(lattice) |
||
xyplot(y~x)</ |
xyplot(y~x)</syntaxhighlight> |
||
===Grammar of graphics=== |
===Grammar of graphics=== |
||
{{libheader|ggplot2}} |
{{libheader|ggplot2}} |
||
< |
<syntaxhighlight lang="r">library(ggplot2) |
||
qplot(x,y)</ |
qplot(x,y)</syntaxhighlight> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
Racket has a built-in plotting library |
Racket has a built-in plotting library |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(require plot) |
(require plot) |
||
Line 2,605: | Line 2,605: | ||
(plot-new-window? #t) |
(plot-new-window? #t) |
||
(plot (points (map vector x y)))</ |
(plot (points (map vector x y)))</syntaxhighlight> |
||
This opens a new window with this image (with interactive zooming) |
This opens a new window with this image (with interactive zooming) |
||
Line 2,611: | Line 2,611: | ||
And this |
And this |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(require plot) |
(require plot) |
||
Line 2,618: | Line 2,618: | ||
(plot-new-window? #t) |
(plot-new-window? #t) |
||
(plot (lines (map vector x y)))</ |
(plot (lines (map vector x y)))</syntaxhighlight> |
||
opens a new window with this image |
opens a new window with this image |
||
Line 2,627: | Line 2,627: | ||
{{works with|Rakudo|2018.03}} |
{{works with|Rakudo|2018.03}} |
||
Generate an SVG image file. |
Generate an SVG image file. |
||
<lang |
<syntaxhighlight lang="raku" line>use SVG; |
||
use SVG::Plot; |
use SVG::Plot; |
||
Line 2,641: | Line 2,641: | ||
values => [@y,], |
values => [@y,], |
||
title => 'Coordinate Pairs', |
title => 'Coordinate Pairs', |
||
).plot(:lines);</ |
).plot(:lines);</syntaxhighlight> |
||
[[File:Coordinate-pairs-perl6.svg]] |
[[File:Coordinate-pairs-perl6.svg]] |
||
Line 2,648: | Line 2,648: | ||
===without point labels=== |
===without point labels=== |
||
Example usage: |
Example usage: |
||
< |
<syntaxhighlight lang="rexx">/*REXX program plots X,Y coördinate pairs of numbers with plain (ASCII) characters.*/ |
||
x = 0 1 2 3 4 5 6 7 8 9 |
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 |
y = 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 |
||
Line 2,656: | Line 2,656: | ||
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */ |
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */ |
||
call '$PLOT' $ /*invoke the REXX program: $PLOT */ |
call '$PLOT' $ /*invoke the REXX program: $PLOT */ |
||
exit rc /*stick a fork in it, we're all done. */</ |
exit rc /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
{{out|output|text= when using the default input:}} |
{{out|output|text= when using the default input:}} |
||
<pre> |
<pre> |
||
Line 2,709: | Line 2,709: | ||
===with point labels=== |
===with point labels=== |
||
< |
<syntaxhighlight lang="rexx">/*REXX program plots X,Y coördinate pairs of numbers with plain (ASCII) characters.*/ |
||
x = 0 1 2 3 4 5 6 7 8 9 |
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 |
y = 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 |
||
Line 2,717: | Line 2,717: | ||
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */ |
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */ |
||
call '$PLOT' $ '(LABELDatapoints' /*invoke the REXX program: $PLOT */ |
call '$PLOT' $ '(LABELDatapoints' /*invoke the REXX program: $PLOT */ |
||
exit rc /*stick a fork in it, we're all done. */</ |
exit rc /*stick a fork in it, we're all done. */</syntaxhighlight> |
||
{{out|output|text= when using the default input:}} |
{{out|output|text= when using the default input:}} |
||
<pre> |
<pre> |
||
Line 2,782: | Line 2,782: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
# Project : Plot coordinate pairs |
# Project : Plot coordinate pairs |
||
Line 2,858: | Line 2,858: | ||
label1 { setpicture(p1) show() } |
label1 { setpicture(p1) show() } |
||
return |
return |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
Line 2,868: | Line 2,868: | ||
[[File:Ruby.plotxy.png|300px|thumb|right|gnuplot of x,y arrays]] |
[[File:Ruby.plotxy.png|300px|thumb|right|gnuplot of x,y arrays]] |
||
< |
<syntaxhighlight lang="ruby">require 'gnuplot' |
||
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
||
Line 2,879: | Line 2,879: | ||
end |
end |
||
end |
end |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
{{libheader|Scala}} |
{{libheader|Scala}} |
||
< |
<syntaxhighlight lang="scala">import scala.swing.Swing.pair2Dimension |
||
import scala.swing.{ MainFrame, Panel, Rectangle } |
import scala.swing.{ MainFrame, Panel, Rectangle } |
||
import java.awt.{ Color, Graphics2D, geom } |
import java.awt.{ Color, Graphics2D, geom } |
||
Line 2,988: | Line 2,988: | ||
contents = ui |
contents = ui |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Scilab}}== |
=={{header|Scilab}}== |
||
< |
<syntaxhighlight lang="scilab">--> 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]; |
--> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; |
||
--> plot2d(x,y)</ |
--> plot2d(x,y)</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
{{trans|Perl}} |
{{trans|Perl}} |
||
< |
<syntaxhighlight lang="ruby">require('GD::Graph::points') |
||
var data = [ |
var data = [ |
||
Line 3,008: | Line 3,008: | ||
var format = 'png' |
var format = 'png' |
||
File("qsort-range.#{format}").write(gd.(format), :raw)</ |
File("qsort-range.#{format}").write(gd.(format), :raw)</syntaxhighlight> |
||
=={{header|Stata}}== |
=={{header|Stata}}== |
||
< |
<syntaxhighlight lang="stata">clear |
||
input x y |
input x y |
||
0 2.7 |
0 2.7 |
||
Line 3,026: | Line 3,026: | ||
lines y x |
lines y x |
||
graph export image.png</ |
graph export image.png</syntaxhighlight> |
||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
Line 3,033: | Line 3,033: | ||
[[File:Tcl_Plotxy.png|thumb|right|150px|Screenshot for Tcl code]] |
[[File:Tcl_Plotxy.png|thumb|right|150px|Screenshot for Tcl code]] |
||
This solution does not use existing plotting packages, but constructs the graphics from bare-metal Tk code. |
This solution does not use existing plotting packages, but constructs the graphics from bare-metal Tk code. |
||
< |
<syntaxhighlight lang="tcl">package require Tk |
||
# The actual plotting engine |
# The actual plotting engine |
||
Line 3,088: | Line 3,088: | ||
package require Img |
package require Img |
||
set im [image create photo -data .c] |
set im [image create photo -data .c] |
||
$im write plotxy.png -format PNG</ |
$im write plotxy.png -format PNG</syntaxhighlight> |
||
Of course, if we were generating an encapsulated postscript version, we would be able to do that directly. |
Of course, if we were generating an encapsulated postscript version, we would be able to do that directly. |
||
Line 3,096: | Line 3,096: | ||
[[File:Plotxy-TI-89.png|thumb|right|200px|TI-89 screenshot]] |
[[File:Plotxy-TI-89.png|thumb|right|200px|TI-89 screenshot]] |
||
< |
<syntaxhighlight lang="ti89b">FnOff |
||
PlotsOff |
PlotsOff |
||
NewPlot 1, 1, x, y |
NewPlot 1, 1, x, y |
||
ZoomData</ |
ZoomData</syntaxhighlight> |
||
=={{header|Ursala}}== |
=={{header|Ursala}}== |
||
Line 3,107: | Line 3,107: | ||
Here's the way to do it just as a quick check (all default settings |
Here's the way to do it just as a quick check (all default settings |
||
and dots connected with straight lines). |
and dots connected with straight lines). |
||
< |
<syntaxhighlight lang="ursala">#import std |
||
#import flo |
#import flo |
||
#import fit |
#import fit |
||
Line 3,117: | Line 3,117: | ||
#output dot'tex' latex_document+ plot |
#output dot'tex' latex_document+ plot |
||
main = visualization[curves: <curve[points: ~&p/x y]>]</ |
main = visualization[curves: <curve[points: ~&p/x y]>]</syntaxhighlight> |
||
([http://i25.tinypic.com/33oi74j.jpg output]) |
([http://i25.tinypic.com/33oi74j.jpg output]) |
||
Line 3,125: | Line 3,125: | ||
labeled. |
labeled. |
||
< |
<syntaxhighlight lang="ursala">main = |
||
visualization[ |
visualization[ |
||
Line 3,141: | Line 3,141: | ||
scattered: true, |
scattered: true, |
||
points: ~&p/x y, |
points: ~&p/x y, |
||
attributes: {'linecolor': 'black'}]>]</ |
attributes: {'linecolor': 'black'}]>]</syntaxhighlight> |
||
([http://i32.tinypic.com/x1x6cz.jpg output]) |
([http://i32.tinypic.com/x1x6cz.jpg output]) |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
Using Excel |
Using Excel |
||
< |
<syntaxhighlight lang="vb">Private Sub plot_coordinate_pairs(x As Variant, y As Variant) |
||
Dim chrt As Chart |
Dim chrt As Chart |
||
Set chrt = ActiveSheet.Shapes.AddChart.Chart |
Set chrt = ActiveSheet.Shapes.AddChart.Chart |
||
Line 3,165: | Line 3,165: | ||
y = [{2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0}] |
y = [{2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0}] |
||
plot_coordinate_pairs x, y |
plot_coordinate_pairs x, y |
||
End Sub</ |
End Sub</syntaxhighlight> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|DOME}} |
{{libheader|DOME}} |
||
< |
<syntaxhighlight lang="ecmascript">import "graphics" for Canvas, ImageData, Color |
||
import "dome" for Window |
import "dome" for Window |
||
import "math" for Point |
import "math" for Point |
||
Line 3,233: | Line 3,233: | ||
} |
} |
||
var Game = PlotCoordinates.new(500, 500)</ |
var Game = PlotCoordinates.new(500, 500)</syntaxhighlight> |
||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
Line 3,242: | Line 3,242: | ||
[[File:PlotXPL0.png|140px|thumb|right|Output]] |
[[File:PlotXPL0.png|140px|thumb|right|Output]] |
||
< |
<syntaxhighlight lang="xpl0">include c:\cxpl\codes; \intrinsic 'code' declarations |
||
def ScrW=640, ScrH=480, VidMode=$101; |
def ScrW=640, ScrH=480, VidMode=$101; |
||
Line 3,275: | Line 3,275: | ||
if ChIn(1) then []; \wait for key |
if ChIn(1) then []; \wait for key |
||
SetVid(3); \restore text |
SetVid(3); \restore text |
||
]</ |
]</syntaxhighlight> |
||
=={{header|Yorick}}== |
=={{header|Yorick}}== |
||
< |
<syntaxhighlight lang="yorick">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]; |
y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; |
||
window, 0; |
window, 0; |
||
plmk, y, x; |
plmk, y, x; |
||
window, 1; |
window, 1; |
||
plg, y, x, marks=0;</ |
plg, y, x, marks=0;</syntaxhighlight> |
||
<gallery> |
<gallery> |
||
File:Plotxy-yorick-plmk.png|Output with plmk |
File:Plotxy-yorick-plmk.png|Output with plmk |
||
Line 3,294: | Line 3,294: | ||
A program can of course supply commands and data to gnuplot as prepared files. For the spirit of controlling plotting with the native language however, this example shows how commands and data can be prepared programmatically and supplied to gnuplot through stdin. |
A program can of course supply commands and data to gnuplot as prepared files. For the spirit of controlling plotting with the native language however, this example shows how commands and data can be prepared programmatically and supplied to gnuplot through stdin. |
||
< |
<syntaxhighlight lang="zkl">#<<< |
||
cmd:=0'| |
cmd:=0'| |
||
#set term wxt # X11 |
#set term wxt # X11 |
||
Line 3,316: | Line 3,316: | ||
gnuplot:=System.popen("gnuplot","w"); |
gnuplot:=System.popen("gnuplot","w"); |
||
gnuplot.write(cmd); gnuplot.flush(); |
gnuplot.write(cmd); gnuplot.flush(); |
||
ask("Hit return to finish"); gnuplot.close();</ |
ask("Hit return to finish"); gnuplot.close();</syntaxhighlight> |