Mojca and Peter, thanks very much for your responses. I used Peter's solution and it worked beautifully.
Curiouslearn schrieb:you accumulate the rounding error with every step of the loop. try to avoid such 'low value' steps if possible.
Hi,
I want the labels as (0.5,0.55,0.6,0.65,0.7,...,1) or (0.50,0.55,0.60,0.65,0.70,...,1). Either of these two is fine.
I tried the following code for this.
\starttext
\startuseMPgraphic{labeltest}
numeric rmin,rmax;
rmin := 0.5; rmax := 1;
ux := 25cm; uy :=10cm;
% draw axes
draw (rmin,0)*ux -- (rmax+0.1,0)*ux;
draw (rmin,0)*ux -- (rmin*ux,(1.1)*uy);
for x = 0.5 step 0.05 until 1.1:
label.bot(textext(decimal(x)),(x*ux,x*uy));
for x = 10 step 1 until 22: % 0.05*20 to get an integer loop index
tx := x/20; % correct value
label.bot(textext(decimal(tx)),(tx*ux,tx*uy));
Best wishes, Peter
endfor;------------------------------------------------------------------------
\stopuseMPgraphic
\useMPgraphic{labeltest}
\stoptext
I get (0.5,0.55, 0.6,0.65001,0.70001,0.75002,...,1.00003) instead. I don't understand why I get more than 2 digits after 0.6. Is there a way to restrict the number of digits after the decimal point.
Thanks very much.
___________________________________________________________________________________
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
--
"Es ist doch ein Trost,
das Geldgier manchmal blöd macht."
- Kottan in "Kottan ermittelt", Folge 9: "Die Einteilung" -
___________________________________________________________________________________
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________