* Add labels to a grid (Metafun)
@ 2015-03-06 17:15 Fabrice Couvreur
2015-03-06 17:38 ` Alan BRASLAU
0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Couvreur @ 2015-03-06 17:15 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 975 bytes --]
To add labels to a grid, Hans wrote a macro hlintext (Min, Max, Step, Lenght
, Format). I do not know what to put in "Format".
Best regards,
Fabrice
\definecolor[mycolor][c=.4,m=0,y=0,k=0]
\starttext
\start
\switchtobodyfont[small]
\startMPcode
input tex;
numeric xmin, xmax, ymin, ymax;
xmin := 0; xmax := 22; ymax :=460 ;ymin:=0; u := 0.5cm; v:= 0.025cm;
drawoptions(withpen pencircle scaled 0.5pt withcolor
\MPcolor{mycolor});
draw hlingrid(ymin,ymax,20,11.5cm,11cm);
draw vlingrid(xmin,xmax,2,11cm,11.5cm);
drawoptions(withpen pencircle scaled 1pt) ;
drawarrow (0,0)--(22,0) scaled u ;
drawarrow (0,0)--(0,460) scaled v ;
for i=0 step 2 until 20 :
label.bot(TEX("$"&decimal(i)&"$"),(i,0)*u);
endfor;
for i=0 step 20 until 440:
label.lft(TEX("$"&decimal(i)&"$"),(0,i)*v);
endfor;
label.bot( "$x$",(10.8cm,-0.1cm)) ;
label.rt( "$y$",(0.1cm,11.3cm)) ;
\stopMPcode
\stop
\stoptext
[-- Attachment #1.2: Type: text/html, Size: 2361 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Add labels to a grid (Metafun)
2015-03-06 17:15 Add labels to a grid (Metafun) Fabrice Couvreur
@ 2015-03-06 17:38 ` Alan BRASLAU
2015-03-06 18:11 ` Fabrice
0 siblings, 1 reply; 3+ messages in thread
From: Alan BRASLAU @ 2015-03-06 17:38 UTC (permalink / raw)
To: Fabrice Couvreur; +Cc: mailing list for ConTeXt users
On Fri, 6 Mar 2015 18:15:09 +0100
Fabrice Couvreur <fabrice1.couvreur@gmail.com> wrote:
> To add labels to a grid, Hans wrote a macro hlintext (Min, Max, Step,
> Lenght, Format). I do not know what to put in "Format".
it is a string format specifier such as "%g", "%f", "%d", ...
Since the % can sometimes cause problems being interpreted as a comment
character, it is usually replaced in Metafun by @, as in "@g".
Alan
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Add labels to a grid (Metafun)
2015-03-06 17:38 ` Alan BRASLAU
@ 2015-03-06 18:11 ` Fabrice
0 siblings, 0 replies; 3+ messages in thread
From: Fabrice @ 2015-03-06 18:11 UTC (permalink / raw)
To: ntg-context
thank you very much Alain, I think I understood for the format "@d" but
for other formats, I will need documentation.
Fabrice
\definecolor[mycolor][c=.4,m=0,y=0,k=0]
\starttext
\start
\switchtobodyfont[small]
\startMPcode
xmin := 0; xmax := 22; ymax :=460 ;ymin:=0; u := 0.5cm; v:= 0.025cm;
drawoptions(withpen pencircle scaled 0.5pt withcolor
\MPcolor{mycolor});
draw hlingrid(ymin,ymax,20,11.5cm,11cm);
draw vlingrid(xmin,xmax,2,11cm,11.5cm);
drawoptions(withpen pencircle scaled 1pt) ;
drawarrow (0,0)--(22,0) scaled u ;
drawarrow (0,0)--(0,460) scaled v ;
draw vlintext(0,20,2,10cm,"@d") shifted (0,-0.25cm) ;
draw hlintext(0,420,20,11cm,"@d") shifted (-0.35cm,0) ;
label.bot( "$x$",(10.8cm,-0.1cm)) ;
label.lft( "$y$",(-0.1cm,11.4cm)) ;
\stopMPcode
\stop
\stoptext
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-06 18:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 17:15 Add labels to a grid (Metafun) Fabrice Couvreur
2015-03-06 17:38 ` Alan BRASLAU
2015-03-06 18:11 ` Fabrice
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).