![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Hi Aditya, Following your explanations in https://adityam.github.io/context-blog/post/new-metafun-interface/ I wrote an environment in order to display the graph of a function on a grid which can be adapted to each case. Assuming that I have an MPinstance named GridAxis (for example) which can dispaly a grid and axes, how can I call it and write a line such as draw function (1,"x","x*x/4 - 2.5",xmin,xmax,.001) scaled sx ; without changing the part whichh is included in \startMPdefinitions, in oder to draw the above function on that grid ? Thanks for your help: Otared PS: Here is my definition of GridAxis (I guess many parts of it could be better written…) \defineMPinstance[GridAxis] [ format=metafun, extensions=yes, initializations=yes, method=double, ] \startMPdefinitions{GridAxis} def GridAxisPlot = applyparameters "GridAxisPlot" "do_GridAxisPlot" enddef ; presetparameters "GridAxisPlot" [ xmin = -2.5, xmax = 2.5, ymin = -2.5, ymax = 2.5, dx = 1, dy = 1, sx = 5mm, sy = 5mm, scale = 0.5, grid = true, xaxisnumbers = true, yaxisnumbers = true, showmyorigin = true, style = "\switchtobodyfont[8pt]", ]; vardef do_GridAxisPlot = image ( pushparameters "GridAxisPlot"; newnumeric xmin, xmax, ymin, ymax; xmin := getparameter "xmin"; xmax := getparameter "xmax"; ymin := getparameter "ymin"; ymax := getparameter "ymax"; newnumeric sx, sy; sx := getparameter "sx"; sy := getparameter "sy"; newnumeric dx, dy; dx := getparameter "dx"; dy := getparameter "dy"; newpath xaxis, yaxis; xaxis := (xmin*sx, 0) -- (xmax*sx, 0) ; yaxis := (0, ymin*sy) -- (0, ymax*sy) ; newpath xtick, ytick; xtick := (-0.1sx, 0) -- (0.1sx, 0); ytick := (0, -0.1sy) -- (0, 0.1sy); newstring style; style := getparameter "style"; pickup pencircle scaled .1mm ; newboolean grid; grid := getparameter "grid"; newboolean xaxisnumbers ; xaxisnumbers := getparameter "xaxisnumbers" ; newboolean yaxisnumbers ; yaxisnumbers := getparameter "yaxisnumbers" ; for x = dx step dx until xmax : if grid : draw yaxis shifted (x*sx, 0) withcolor 0.75white ; fi draw ytick shifted (x*sx, 0); if xaxisnumbers : label.bot(style & decimal x, (x*sx, 0)); fi endfor newboolean showmyorigin ; showmyorigin := getparameter "showmyorigin" ; if showmyorigin : label.lrt(style & "0", origin) ; fi for x = -dx step -dx until xmin : if grid : draw yaxis shifted (x*sx, 0) withcolor 0.75white; fi draw ytick shifted (x*sx, 0); if xaxisnumbers : label.bot(style & decimal x, (x*sx, 0)); fi endfor for y = dy step dy until ymax : if grid : draw xaxis shifted (0, y*sy) withcolor 0.75white; fi draw xtick shifted (0, y*sy); if yaxisnumbers : label.lft(style & decimal y, (0, y*sy)); fi endfor for y = -dy step -dy until ymin : if grid : draw xaxis shifted (0, y*sy) withcolor 0.75white; fi draw xtick shifted (0, y*sy); if yaxisnumbers : label.lft(style & decimal y, (0, y*sy)); fi endfor drawarrow xaxis; drawarrow yaxis; label.rt( style & "$x$", (xmax*sx, 0)); label.top(style & "$y$", (0, ymax*sy)); newpair p ; newnumeric scale; scale := getparameter "scale" ; popparameters; ) enddef; \stopMPdefinitions