September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,14 @@
unset key # Only one data set, so the key is uninformative
plot '-' # '-' can be replaced with a filename, to read data from that file.
0 2.7
1 2.8
2 31.4
3 38.1
4 68.0
5 76.2
6 100.5
7 130.0
8 149.3
9 180.0
e

View file

@ -0,0 +1,75 @@
--
-- demo\rosetta\Plot_coordinate_pairs.exw
--
include pGUI.e
Ihandle dlg, canvas
cdCanvas cddbuffer, cdcanvas
constant 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}
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
integer {width, height} = IupGetIntInt(canvas, "DRAWSIZE")
atom cx,cy,nx,ny
atom {w,h} = {(width-60)/9,(height-60)/180}
cdCanvasActivate(cddbuffer)
cx = 30+x[1]*w
cy = 30+y[1]*h
for i=2 to length(x) do
cdCanvasSetForeground(cddbuffer, CD_BLACK)
nx = 30+(i-1)*w
ny = 30+(i-1)*20*h
{} = cdCanvasTextAlignment(cddbuffer, CD_NORTH)
cdCanvasText(cddbuffer, nx, 25, sprintf("%d",(i-1)))
{} = cdCanvasTextAlignment(cddbuffer, CD_EAST)
cdCanvasText(cddbuffer, 25, ny, sprintf("%3d",(i-1)*20))
cdCanvasSetForeground(cddbuffer, CD_GRAY)
cdCanvasLine(cddbuffer,30,ny,width-30,ny)
cdCanvasLine(cddbuffer,nx,30,nx,height-30)
cdCanvasSetForeground(cddbuffer, CD_BLUE)
nx = 30+floor(x[i]*w)
ny = 30+floor(y[i]*h)
cdCanvasLine(cddbuffer,cx,cy,nx,ny)
cx = nx
cy = ny
end for
cdCanvasSetForeground(cddbuffer, CD_BLACK)
cdCanvasLine(cddbuffer,30,30,width-30,30)
cdCanvasLine(cddbuffer,30,30,30,height-30)
cdCanvasFlush(cddbuffer)
return IUP_DEFAULT
end function
function map_cb(Ihandle ih)
cdcanvas = cdCreateCanvas(CD_IUP, ih)
cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas)
cdCanvasSetBackground(cddbuffer, CD_WHITE)
return IUP_DEFAULT
end function
function esc_close(Ihandle /*ih*/, atom c)
if c=K_ESC then return IUP_CLOSE end if
return IUP_CONTINUE
end function
procedure main()
IupOpen()
canvas = IupCanvas(NULL)
IupSetAttribute(canvas, "RASTERSIZE", "340x340") -- initial size
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
dlg = IupDialog(canvas)
IupSetAttribute(dlg, "TITLE", "Plot coordinate pairs")
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
IupMap(dlg)
IupSetAttribute(canvas, "RASTERSIZE", NULL) -- release the minimum limitation
IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
IupMainLoop()
IupClose()
end procedure
main()

View file

@ -0,0 +1,9 @@
/*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
y = 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0
$=
do j=1 for words(x) /*build a list suitable for $PLOT subr.*/
$=$ word(x, j)','word(y, j) /*add this X,Y coördinate to the $ list*/
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */
call '$PLOT' $ /*invoke the REXX program: $PLOT */
exit rc /*stick a fork in it, we're all done. */

View file

@ -0,0 +1,9 @@
/*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
y = 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0
$=
do j=1 for words(x) /*build a list suitable for $PLOT subr.*/
$=$ word(x, j)','word(y, j) /*add this X,Y coördinate to the $ list*/
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 3,38.1 ··· */
call '$PLOT' $ '(LABELDatapoints' /*invoke the REXX program: $PLOT */
exit rc /*stick a fork in it, we're all done. */

View file

@ -1,9 +0,0 @@
/*REXX program plots coördinate pairs of numbers with plain characters. */
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
$=
do j=1 for words(x) /*build a list suitable for $PLOT*/
$=$ word(x,j)','word(y,j)
end /*j*/ /*$≡ 0,2.7 1,2.8 2,31.4 ···*/
call '$PLOT' $ /*invoke the REXX program: $PLOT.*/
exit rc /*stick a fork in it, we're done.*/

View file

@ -5,4 +5,4 @@
(define y (list 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0))
(plot-new-window? #t)
(plot (points (map vector x y)))
(plot (lines (map vector x y)))

View file

@ -0,0 +1,3 @@
--> 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];
--> plot2d(x,y)

View file

@ -0,0 +1,16 @@
clear
input x y
0 2.7
1 2.8
2 31.4
3 38.1
4 58.0
5 76.2
6 100.5
7 130.0
8 149.3
9 180.0
end
lines y x
graph export image.png

View file

@ -0,0 +1,23 @@
#<<<
cmd:=0'|
#set term wxt # X11
unset key # Only one data set, so the key is uninformative
plot '-' # '-' can be replaced with a filename, to read data from that file.
0 2.7
1 2.8
2 31.4
3 38.1
4 68.0
5 76.2
6 100.5
7 130.0
8 149.3
9 180.0
e
|;
#<<<
gnuplot:=System.popen("gnuplot","w");
gnuplot.write(cmd); gnuplot.flush();
ask("Hit return to finish"); gnuplot.close();