Special Plots in EMT

Sometimes, you want to give plots in Euler Math Toolbox (EMT) a special look. Let us demonstrate an example. The following is the German tax function (no guarantee!).

>function  map s (x:scalar) ...
$  if x<8130 then
$    return 0;
$  elseif x<13470 then y=(x-8130)/10000;
$    return (933.7*y+1400)*y;
$  elseif x<52881 then y=(x-13470)/10000;
$    return (228.74*y+2397)*y+1014;
$  elseif x<250730 then
$    return 0.42*x-8196;
$  else
$    return 0.45*x-15718;
$  endif
>shrinkwindow(>smaller); ...
>plot2d("s",0,125000,xl="x",yl="s",title="German Income Tax"):


This very basic plot is okay. We already applied the shrinkwindow() command with parameter „smaller=true“ to give the y-label a bit more room. This is necessary if the y-labels are bigger numbers. But we might want to do more.

We want to do the following things. We want

  • blue grid lines and text,
  • a larger font,
  • thicker plot lines,
  • added points, where the definition of the tax function changes,
  • an aspect ratio so that the plot becomes more landscape,
  • more room on the left side, where the text S subscript 2012 should appear.

To do this, we must use more primitive routines of EMT.

>clg; ...
>aspect(1.5); setfont(12pt,15cm); ...
>window(250,50,950,880); ...
>col=rgb(0,0,0.4); ...
>defaulttextcolor=col; defaultgridcolor=col; ...
>framecolor(col); ...
>setplot(0,125000,0,s(125000)); frame();  ...
>xgrid(0:25000:125000); ygrid(0:10000:50000); ...
>plot2d("s",>add,thickness=2,color=red); ...
>xlabel("x"); ...
>label(latex("S_{2012}"),-50000,22000); ...
>xp=[8130,13470,52881];  ...


Some of this can be done without calling setplot(), clg() etc. manually. But I wanted to show the basic routines that work beyond the scene in plot2d().

Some remarks need to be made. The function setfont() must be called before the function window() which sets the plot window, since it does also change the plot window to take care of the larger font. Note that some default colors are set by variables and others by functions. This is due to the history of EMT. There should be functions for all default stuff in future versions.

Also, note that we took the easy function label() with special plot coordinates to place the label on the left. This is an easy solution. It might be better to use screen coordinates for the label. To convert for the plot coordinates one can use fromscreen(w,h) so that the versatile function label() can be used.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

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