* Axis macro in MetaFun @ 2021-09-11 14:27 kauśika cittūr via ntg-context 2021-09-11 16:19 ` Hans Hagen via ntg-context 2021-09-11 17:00 ` Hans Hagen via ntg-context 0 siblings, 2 replies; 4+ messages in thread From: kauśika cittūr via ntg-context @ 2021-09-11 14:27 UTC (permalink / raw) To: ntg-context; +Cc: kauśika cittūr Dear All, I am truly grateful for the new additions to MetaFun. It has greatly helped me in producing neat drawings for my academic work. In this connection, I have a few queries. Currently I am using PGFPlots (with ConTeXt) to draw simple plots from CSV data. I was wondering if there is any way to do the same in MetaFuns. That is, is it possible to do something like the following in order to obtain a line plot of the values in the 'data.csv' file? Also is it possible to have the 'labels' be the identical for all points in a given list? \startMPcode draw lmt_axis [ sx = 2mm, sy = 2mm, nx = 80, ny = 40, tx = 15, ty = 15, list = { [ connect = true, color = "darkblue", close = true, points = {data.csv}, labels = {"•"}, ] }, ] withpen pencircle scaled 0.5mm; \stopMPcode My final query: is it possible to specify a co-ordinate transform for any/all of the axes? For instance in my work, I would like to plot the y-axis in the log-scale. Thanks, kauśika ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Axis macro in MetaFun 2021-09-11 14:27 Axis macro in MetaFun kauśika cittūr via ntg-context @ 2021-09-11 16:19 ` Hans Hagen via ntg-context 2021-09-11 17:00 ` Hans Hagen via ntg-context 1 sibling, 0 replies; 4+ messages in thread From: Hans Hagen via ntg-context @ 2021-09-11 16:19 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Hans Hagen, Alan BRASLAU On 9/11/2021 4:27 PM, kauśika cittūr via ntg-context wrote: > My final query: is it possible to specify a co-ordinate transform for any/all > of the axes? For instance in my work, I would like to plot the y-axis in the > log-scale. Alan is working on that when he is in distraction mode ... we have done some preparations already. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Axis macro in MetaFun 2021-09-11 14:27 Axis macro in MetaFun kauśika cittūr via ntg-context 2021-09-11 16:19 ` Hans Hagen via ntg-context @ 2021-09-11 17:00 ` Hans Hagen via ntg-context 2021-09-12 2:07 ` kauśika cittūr via ntg-context 1 sibling, 1 reply; 4+ messages in thread From: Hans Hagen via ntg-context @ 2021-09-11 17:00 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Hans Hagen On 9/11/2021 4:27 PM, kauśika cittūr via ntg-context wrote: > Dear All, > > I am truly grateful for the new additions to MetaFun. It has greatly helped me > in producing neat drawings for my academic work. In this connection, I have a > few queries. > > Currently I am using PGFPlots (with ConTeXt) to draw simple plots from CSV > data. I was wondering if there is any way to do the same in MetaFuns. That is, > is it possible to do something like the following in order to obtain a line > plot of the values in the 'data.csv' file? Also is it possible to have the > 'labels' be the identical for all points in a given list? > > \startMPcode > draw lmt_axis [ > sx = 2mm, sy = 2mm, > nx = 80, ny = 40, > tx = 15, ty = 15, > > list = { > [ > connect = true, > color = "darkblue", > close = true, > points = {data.csv}, > labels = {"•"}, > ] > }, > ] withpen pencircle scaled 0.5mm; > \stopMPcode > It depends on how one has data in the csv, You can patch mlib-scn.lmt (line 659) if type(v) == "table" then return injectpath(v,connector,close) elseif type(v) == "string" then local code = load("return " .. v) if code then return code() end else return injectpair(0,0) end then a string represents a function: \starttext \startluacode io.savedata("temp.csv", "x,y\n10,10\n20,40\n30,30\n") local mycsvsplitter = utilities.parsers.rfc4180splitter() function MP.MyPoints(name) local data = io.loaddata(name) local list = mycsvsplitter(data) table.remove(list,1) for i=1,#list do list[i][1] = tonumber(list[i][1]) list[i][2] = tonumber(list[i][2]) end mp.inject.path(list) end \stopluacode \startMPcode draw lmt_axis [ sx = 2mm, sy = 2mm, nx = 80, ny = 40, tx = 15, ty = 15, list = { [ connect = true, color = "darkblue", close = true, points = "MP.MyPoints('temp.csv')", labels = {"•"}, ] }, ] withpen pencircle scaled 0.5mm; \stopMPcode \stoptext we can of course have some predefined and when we can agree on how these files loo, adding a "csv" is no big deal ... it's all about consistent interfacing ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Axis macro in MetaFun 2021-09-11 17:00 ` Hans Hagen via ntg-context @ 2021-09-12 2:07 ` kauśika cittūr via ntg-context 0 siblings, 0 replies; 4+ messages in thread From: kauśika cittūr via ntg-context @ 2021-09-12 2:07 UTC (permalink / raw) To: mailing list for ConTeXt users, Hans Hagen; +Cc: kauśika cittūr On Saturday, September 11, 2021 10:30:25 PM IST Hans Hagen wrote: > On 9/11/2021 4:27 PM, kauśika cittūr via ntg-context wrote: > > Dear All, > > > > I am truly grateful for the new additions to MetaFun. It has greatly > > helped me in producing neat drawings for my academic work. In this > > connection, I have a few queries. > > > > Currently I am using PGFPlots (with ConTeXt) to draw simple plots from CSV > > data. I was wondering if there is any way to do the same in MetaFuns. That > > is, is it possible to do something like the following in order to obtain > > a line plot of the values in the 'data.csv' file? Also is it possible to > > have the 'labels' be the identical for all points in a given list? > > > > \startMPcode > > > > draw lmt_axis [ > > > > sx = 2mm, sy = 2mm, > > nx = 80, ny = 40, > > tx = 15, ty = 15, > > > > list = { > > > > [ > > > > connect = true, > > color = "darkblue", > > close = true, > > points = {data.csv}, > > labels = {"•"}, > > > > ] > > > > }, > > > > ] withpen pencircle scaled 0.5mm; > > > > \stopMPcode > > It depends on how one has data in the csv, You can patch mlib-scn.lmt > (line 659) > > if type(v) == "table" then > return injectpath(v,connector,close) > elseif type(v) == "string" then > local code = load("return " .. v) > if code then > return code() > end > else > return injectpair(0,0) > end > > then a string represents a function: > > \starttext > > \startluacode > io.savedata("temp.csv", "x,y\n10,10\n20,40\n30,30\n") > > local mycsvsplitter = utilities.parsers.rfc4180splitter() > > function MP.MyPoints(name) > local data = io.loaddata(name) > local list = mycsvsplitter(data) > table.remove(list,1) > for i=1,#list do > list[i][1] = tonumber(list[i][1]) > list[i][2] = tonumber(list[i][2]) > end > mp.inject.path(list) > end > > \stopluacode > > \startMPcode > draw lmt_axis [ > sx = 2mm, sy = 2mm, > nx = 80, ny = 40, > tx = 15, ty = 15, > > list = { > [ > connect = true, > color = "darkblue", > close = true, > points = "MP.MyPoints('temp.csv')", > labels = {"•"}, > ] > }, > ] withpen pencircle scaled 0.5mm; > \stopMPcode > > \stoptext > > we can of course have some predefined and when we can agree on how these > files loo, adding a "csv" is no big deal ... it's all about consistent > interfacing > > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- Dear Hans, Many thanks for your detailed guidance. I think for now this patch should suffice for my simple needs. Best, kauśika ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-12 2:07 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-11 14:27 Axis macro in MetaFun kauśika cittūr via ntg-context 2021-09-11 16:19 ` Hans Hagen via ntg-context 2021-09-11 17:00 ` Hans Hagen via ntg-context 2021-09-12 2:07 ` kauśika cittūr via ntg-context
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).