The horizontal axis label of mwe below has 0.0 (showing tenths; pdf attached; filename is mwe.tex). I expected it to show -1, 0, 1, 2, 3, (integers only). Can this be formatted? % -1 1 % 0 1 % 0 2 % 1 1 % 2 1 % 2 2 % 2 3 % 2 4 % 3 1 % 3 2 \usemodule[m-graph] \startMPpage[instance=graph, offset=5mm] labeloffset:=3mm; draw begingraph(8cm,4cm); setrange(-1.5,0.5,3.5,5); picture symbol ; symbol := image(draw fullcircle scaled 5mm withcolor red;); gdata("mwe.tex", v, clearxy; glabel(symbol,v1,v2) ; ); frame.bot shifted(0,-2mm) ; autogrid(otick.bot,) shifted(0,-2mm); endgraph; \stopMPpage Thanks! John
On Sat, 16 Jul 2022 13:21:06 -0400
John Kitzmiller via ntg-context
The horizontal axis label of mwe below has 0.0 (showing tenths; pdf attached; filename is mwe.tex).
I expected it to show -1, 0, 1, 2, 3, (integers only). Can this be formatted?
% -1 1 % 0 1 % 0 2 % 1 1 % 2 1 % 2 2 % 2 3 % 2 4 % 3 1 % 3 2
\usemodule[m-graph] \startMPpage[instance=graph, offset=5mm] labeloffset:=3mm; draw begingraph(8cm,4cm); setrange(-1.5,0.5,3.5,5); picture symbol ; symbol := image(draw fullcircle scaled 5mm withcolor red;); gdata("mwe.tex", v, clearxy; glabel(symbol,v1,v2) ; ); frame.bot shifted(0,-2mm) ; autogrid(otick.bot,) shifted(0,-2mm); endgraph; \stopMPpage
Thanks! John
% Autoform is the format string used by autogrid % Autoform_X, Autoform_Y if defined, are used instead string Autoform ; Autoform = "%g"; % string Autoform_X ; Autoform_X := "@.0e" ; % string Autoform_Y ; Autoform_Y := "@.0e" ;
On Sat, 16 Jul 2022 13:21:06 -0400 John Kitzmiller via ntg-context
wrote: The horizontal axis label of mwe below has 0.0 (showing tenths; pdf attached; filename is mwe.tex).
I expected it to show -1, 0, 1, 2, 3, (integers only). Can this be formatted?
% -1 1 % 0 1 % 0 2 % 1 1 % 2 1 % 2 2 % 2 3 % 2 4 % 3 1 % 3 2
\usemodule[m-graph] \startMPpage[instance=graph, offset=5mm] labeloffset:=3mm; draw begingraph(8cm,4cm); setrange(-1.5,0.5,3.5,5); picture symbol ; symbol := image(draw fullcircle scaled 5mm withcolor red;); gdata("mwe.tex", v, clearxy; glabel(symbol,v1,v2) ; ); frame.bot shifted(0,-2mm) ; autogrid(otick.bot,) shifted(0,-2mm); endgraph; \stopMPpage
Thanks! John
On Wed, Jul 20, 2022 at 9:48 AM Alan
wrote: % Autoform is the format string used by autogrid % Autoform_X, Autoform_Y if defined, are used instead string Autoform ; Autoform = "%g";
% string Autoform_X ; Autoform_X := "@.0e" ; % string Autoform_Y ; Autoform_Y := "@.0e" ;
Thanks Alan. I see those lines in the module listing, but could you provide some guidance on usage? Can the (re)formatting be done from my input file, or do I need to modify mp-grap.mpiv, or some other way? (Apologies for double-dipping, but usage direction for the least-squares fit extension in m-graph would be a gift.)
On Thu, 21 Jul 2022 17:56:45 -0400
John Kitzmiller
On Wed, Jul 20, 2022 at 9:48 AM Alan
wrote: % Autoform is the format string used by autogrid % Autoform_X, Autoform_Y if defined, are used instead string Autoform ; Autoform = "%g";
% string Autoform_X ; Autoform_X := "@.0e" ; % string Autoform_Y ; Autoform_Y := "@.0e" ;
Thanks Alan. I see those lines in the module listing, but could you provide some guidance on usage? Can the (re)formatting be done from my input file, or do I need to modify mp-grap.mpiv, or some other way?
(Apologies for double-dipping, but usage direction for the least-squares fit extension in m-graph would be a gift.)
You can set these strings in your source file, no need to have a private copy of mp-grap.mpiv Autoform := "@.0e" ; or, if you want different formats for the X and Y axes: string Autoform_X ; Autoform_X := "@.0e" ; % or whatever you want ... string Autoform_Y ; Autoform_Y := "@.0e" ; A few notes: Autoform_X and Autoform_Y are used if known, otherwise it falls back on the string Autoform. The format string uses "@" rather then "%", as % is normally scanned as a comment. Alan
On Tue, Jul 26, 2022 at 1:51 PM Alan
On Thu, 21 Jul 2022 17:56:45 -0400 John Kitzmiller
wrote: On Wed, Jul 20, 2022 at 9:48 AM Alan
wrote: % Autoform is the format string used by autogrid % Autoform_X, Autoform_Y if defined, are used instead string Autoform ; Autoform = "%g";
% string Autoform_X ; Autoform_X := "@.0e" ; % string Autoform_Y ; Autoform_Y := "@.0e" ;
Thanks Alan. I see those lines in the module listing, but could you provide some guidance on usage? Can the (re)formatting be done from my input file, or do I need to modify mp-grap.mpiv, or some other way?
(Apologies for double-dipping, but usage direction for the least-squares fit extension in m-graph would be a gift.)
You can set these strings in your source file, no need to have a private copy of mp-grap.mpiv
Autoform := "@.0e" ;
or, if you want different formats for the X and Y axes:
string Autoform_X ; Autoform_X := "@.0e" ; % or whatever you want ... string Autoform_Y ; Autoform_Y := "@.0e" ;
A few notes:
Autoform_X and Autoform_Y are used if known, otherwise it falls back on the string Autoform.
The format string uses "@" rather then "%", as % is normally scanned as a comment.
Thank you again, but the "0.0" remains unchanged. The only way I've been able to succeed is with a for loop to label explicitly. See mwe below for things I've attempted. The last two for lines seems to be what it takes (with the other Auto lines commented out of course.) % 0 0 % 1 1 % 2 3 % 3 5 \enabletrackers[metapost.showlog] \usemodule[m-graph] \startMPpage[instance=graph, offset=5mm] draw begingraph(160, 100); gdraw "mwe-2.tex" plot circles(0); Autoform := "@0.g" ; autogrid(otick.bot,otick.lft); % for x=auto.x: otick.bot(format("@g",x),x); endfor; % for y=auto.y: otick.lft(format("@g",y),y); endfor; % for x = 0 upto 3: otick.bot(x,x); endfor; % for y = 0 upto 5: otick.lft(y,y); endfor; endgraph; \stopMPpage
On Thu, 21 Jul 2022 17:56:45 -0400
John Kitzmiller
(Apologies for double-dipping, but usage direction for the least-squares fit extension in m-graph would be a gift.)
The least-squares fit (to a polynomial) is a deterministic calculation, not an arbitrary non-linear search. As such, it is very robust. Certain (useful) functions, a Gaussian peak for example, can be suitably transformed to a polynomial function, so these are handled as well, robustly. Examples are given as comments in mp-grap.mpiv that you can follow. I can send you off-list an adapted version of the original John Hobby documentation, with extensions described. Note that the m-graph module is simply a re-write of the John Hobby graph macros, taking advantage of floating-point MetaPost (thus simplified). %%%%%%%%%%%%%%%%%%%%%%%% I have been working on a completely new luagraph module that does much in lua. It has, notably, arbitrary coordinate systems. This has been a moving target as I put more and more into lua and less and less in Metapost. I have also been playing chase with the development of luametatex (and have fallen behind). Alan
On Tue, Jul 26, 2022 at 2:10 PM Alan
On Thu, 21 Jul 2022 17:56:45 -0400 John Kitzmiller
wrote: (Apologies for double-dipping, but usage direction for the least-squares fit extension in m-graph would be a gift.)
The least-squares fit (to a polynomial) is a deterministic calculation, not an arbitrary non-linear search. As such, it is very robust.
Certain (useful) functions, a Gaussian peak for example, can be suitably transformed to a polynomial function, so these are handled as well, robustly.
Examples are given as comments in mp-grap.mpiv that you can follow. Also attached is an adapted version of the original John Hobby documentation, with extensions described.
Note that the m-graph module is simply a re-write of the John Hobby graph macros, taking advantage of floating-point MetaPost (thus simplified).
%%%%%%%%%%%%%%%%%%%%%%%%
I have been working on a completely new luagraph module that does much in lua. It has, notably, arbitrary coordinate systems.
This has been a moving target as I put more and more into lua and less and less in Metapost. I have also been playing chase with the development of luametatex (and have fallen behind).
Alan
Thanks for the modified documentation of the graph macros. It has been a great help. Is it in the lmtx distribution somewhere? I read about the upcoming luagraph in mag-1104-mkiv.pdf (This Way 11/11/2019) and have also played a bit with LuaMetaFun and Aditya's blog post. Looking forward to that development, thank you! John
participants (2)
-
Alan
-
John Kitzmiller