ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* m-graph label
@ 2022-07-16 17:21 John Kitzmiller via ntg-context
  2022-07-20 13:48 ` Alan via ntg-context
  0 siblings, 1 reply; 7+ messages in thread
From: John Kitzmiller via ntg-context @ 2022-07-16 17:21 UTC (permalink / raw)
  To: ntg-context; +Cc: John Kitzmiller


[-- Attachment #1.1: Type: text/plain, Size: 656 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1464 bytes --]

[-- Attachment #2: mwe.pdf --]
[-- Type: application/pdf, Size: 7211 bytes --]

[-- Attachment #3: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-16 17:21 m-graph label John Kitzmiller via ntg-context
@ 2022-07-20 13:48 ` Alan via ntg-context
  2022-07-21 21:56   ` John Kitzmiller via ntg-context
  0 siblings, 1 reply; 7+ messages in thread
From: Alan via ntg-context @ 2022-07-20 13:48 UTC (permalink / raw)
  To: John Kitzmiller via ntg-context; +Cc: Alan, John Kitzmiller

On Sat, 16 Jul 2022 13:21:06 -0400
John Kitzmiller via ntg-context <ntg-context@ntg.nl> 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

% 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" ; 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-20 13:48 ` Alan via ntg-context
@ 2022-07-21 21:56   ` John Kitzmiller via ntg-context
  2022-07-26 17:51     ` Alan via ntg-context
  2022-07-26 18:26     ` Alan via ntg-context
  0 siblings, 2 replies; 7+ messages in thread
From: John Kitzmiller via ntg-context @ 2022-07-21 21:56 UTC (permalink / raw)
  To: Alan; +Cc: John Kitzmiller, John Kitzmiller via ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1564 bytes --]

> On Sat, 16 Jul 2022 13:21:06 -0400
> John Kitzmiller via ntg-context <ntg-context@ntg.nl> 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 <braslau.list@comcast.net> 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.)

[-- Attachment #1.2: Type: text/html, Size: 2761 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-21 21:56   ` John Kitzmiller via ntg-context
@ 2022-07-26 17:51     ` Alan via ntg-context
  2022-07-30 21:04       ` John Kitzmiller via ntg-context
  2022-07-26 18:26     ` Alan via ntg-context
  1 sibling, 1 reply; 7+ messages in thread
From: Alan via ntg-context @ 2022-07-26 17:51 UTC (permalink / raw)
  To: John Kitzmiller; +Cc: Alan, John Kitzmiller via ntg-context

On Thu, 21 Jul 2022 17:56:45 -0400
John Kitzmiller <jkitzm@gmail.com> wrote:

> > On Wed, Jul 20, 2022 at 9:48 AM Alan <braslau.list@comcast.net>
> > 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-21 21:56   ` John Kitzmiller via ntg-context
  2022-07-26 17:51     ` Alan via ntg-context
@ 2022-07-26 18:26     ` Alan via ntg-context
  2022-07-30 21:14       ` John Kitzmiller via ntg-context
  1 sibling, 1 reply; 7+ messages in thread
From: Alan via ntg-context @ 2022-07-26 18:26 UTC (permalink / raw)
  To: John Kitzmiller; +Cc: Alan, John Kitzmiller via ntg-context

On Thu, 21 Jul 2022 17:56:45 -0400
John Kitzmiller <jkitzm@gmail.com> 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.
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-26 17:51     ` Alan via ntg-context
@ 2022-07-30 21:04       ` John Kitzmiller via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: John Kitzmiller via ntg-context @ 2022-07-30 21:04 UTC (permalink / raw)
  To: Alan; +Cc: John Kitzmiller, John Kitzmiller via ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 2164 bytes --]

On Tue, Jul 26, 2022 at 1:51 PM Alan <braslau.list@comcast.net> wrote:

> On Thu, 21 Jul 2022 17:56:45 -0400
> John Kitzmiller <jkitzm@gmail.com> wrote:
>
> > > On Wed, Jul 20, 2022 at 9:48 AM Alan <braslau.list@comcast.net>
> > > 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

[-- Attachment #1.2: Type: text/html, Size: 3469 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: m-graph label
  2022-07-26 18:26     ` Alan via ntg-context
@ 2022-07-30 21:14       ` John Kitzmiller via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: John Kitzmiller via ntg-context @ 2022-07-30 21:14 UTC (permalink / raw)
  To: Alan; +Cc: John Kitzmiller, John Kitzmiller via ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1607 bytes --]

On Tue, Jul 26, 2022 at 2:10 PM Alan <braslau.list@comcast.net> wrote:

> On Thu, 21 Jul 2022 17:56:45 -0400
> John Kitzmiller <jkitzm@gmail.com> 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

[-- Attachment #1.2: Type: text/html, Size: 2693 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-30 21:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 17:21 m-graph label John Kitzmiller via ntg-context
2022-07-20 13:48 ` Alan via ntg-context
2022-07-21 21:56   ` John Kitzmiller via ntg-context
2022-07-26 17:51     ` Alan via ntg-context
2022-07-30 21:04       ` John Kitzmiller via ntg-context
2022-07-26 18:26     ` Alan via ntg-context
2022-07-30 21:14       ` John Kitzmiller 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).