EMT – Using Gnuplot

The following functions (or similar code) will be added to the next version of EMT.

>function mxmsetpng (w=1000,h=1000) ...
$ term="pngcairo size "+w+","+h;
$ mxm(''set_plot_option([gnuplot_term,"''+term+''"]);'');
$ file=strrepl(eulerhome()+"gnuout.png","\","/");
$ mxm(''set_plot_option([gnuplot_out_file,"''+file+''"])'');
$ gnufile$$=eulerhome()+"gnuout.png";
$endfunction
>function mxmins (lines=32) ...
$ loadimg(lines,gnufile$$);
$endfunction

With that you can let Gnu Plot produce a PNG, which can be loaded into a notebook.

>mxmsetpng(500,500);
>r &= (exp(cos(t))-2*cos(4*t)-sin(t/12)^5); ...
>&plot2d([parametric, r*sin(t), r*cos(t),  ...
>   [t, -8*%pi, 8*%pi], [nticks, 2000]]);
>mxmins;

test-001

The same plot with Euler looks like this.

>plot2d(&"r*sin(t) with t=x",&"r*cos(t) with t=x",xmin=-8pi,xmax=8pi, ...
>  n=1000,color=blue):

test-003

Update: I changed „png“ to „pngcairo“, which produces a nicer image.

Update: For the next, version, the following will be possible.

>&plot2d(x^3-x,[x,-2,2]):

This inserts the output of Gnu Plot automatically. It is still possible to use mxmpng() before this call. This will be necessary for other aspect ratios than 1:1.

>mxmsetpng(600,400);
>&plot2d(x^3-x,[x,-2,2]):

test-001

The closest you can get in EMT to this is the following.

>gridstyle(".",".",black,black,black); aspect(3/2); margin(0); ...
>plot2d("x^3-x",-2,2,color=blue,grid=6,>vertical,xl="x",yl="x^3-x"):

test-002

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.