kill(all)$

maxima : appendix how to draw line on the canvas,version 1.0
peter.vlasschaert@gmail.com,24/09/2020

 wxplot2d ([discrete,[[1,2],[3,5]]],[x,0,10.0],[y,0,10.0],same_xy)$

line2d(xa,ya,xb,yb,cl):=
wxplot2d ([discrete,[[xa,ya],[xb,yb]]],
    [x,0,10.0],[y,0,10.0],[color,cl],same_xy,
    [box,false],[axes,false]
)$

line2d(1,2,3,5,red),wxplot_size=[1024,768];

line2d(1,2,3,5,red),wxplot_size=[1024,768];

test :[1,2,3,5,4,5,7,8];

for i:1 thru length(test)/4 do(
line2d(test[i],test[i+1],test[i+2],test[i+3],red),
    wxplot_size=[1024,768]
)$

line2dl(m,cl):=
for i:1 thru 2 do(
wxplot2d ([discrete,[[m[i],m[i+1]],[m[i+2],m[i+2]]]],
    [x,0,10.0],[y,0,10.0],[color,cl],same_xy,
    [box,false],[axes,false]
))$

line2dl(test,red)$

line2dl2(m,cl):=wxplot2d ([discrete,m],
    [x,0,10.0],[y,0,10.0],[color,cl],same_xy,
    [box,false],[axes,false])$

test1:[[1,2],[3,5],[0,0],[4,2],[5,9]];

line2dl2(test1,red);

Multiple Plots in Maxima   ( list plot)
===================

ref1:https://stackoverflow.com/questions/15706857/multiple-plots-in-maxima
ref2:https://themaximalist.org/2017/04/19/multiple-plots-in-a-single-maxima-figure/

→ a) intro

p: []$
p: endcons([discrete, [[1,2],[3,5]]], p)$
p: endcons([discrete, [[4,5],[7,8]]], p)$

/* display all plots in p */
wxplot2d(p);

→ b) pratical

mq:[1,2,3,5,4,5,7,8]$

1e) data structure 'makelist'
--------------------------------------

mqa:makelist([[mq[4*(i-1)+1],mq[4*(i-1)+2]],
  [mq[4*(i-1)+3],mq[4*(i-1)+4]]],i,1,length(mq)/4);

mq1:mqa$

q:[]$
for i:1 thru 2 do
                 (
q:endcons([discrete, mq1[i]], q)
                 )$

2e) plot data structure
------------------------------

/* display all plots in p */
line2df(am):=wxplot2d(am, [x,0,10.0],[y,0,10.0],
    [color,red,green],same_xy,
    [box,true],[axes,true],[legend,false],
    [title,"multiple plot on the canvas "])$

→ optimized code.

grind(line2df)$

line2df(q); /*same :hold on in matlab */