Re: Decimal point in printed numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg41595] Re: [mg41577] Decimal point in printed numbers
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Wed, 28 May 2003 04:57:27 -0400 (EDT)
- References: <200305270925.FAA02370@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
It depends on how you generate your labels. I give you an example. Suppose
you want to place the following labels along the x axis in the graph of a 45
degree line:
In[1]:=
xlabs = Round[10*Table[j/3, {j, -9, 9, 2}]]/10.
Out[1]=
{-3.,-2.3,-1.7,-1.,-0.3,0.3,1.,1.7,2.3,3.}
In[2]:=
Plot[x, {x, -3, 3}, Ticks -> {xlabs, Automatic}];
Here the integral values do not show the decimal point, and the fractional
values appear in decimal form. However, if your method still produces
numbers in an inconvenient format, I suggest you convert them to strings and
then use the Ticks options to print them in the proper places.
Tomas Garza
Mexico City
----- Original Message -----
From: "Jan Rychter" <jan at rychter.com>
To: mathgroup at smc.vnet.net
Subject: [mg41595] [mg41577] Decimal point in printed numbers
> I'm generating labels for axes in a plot. If I numericalize (N[]) them,
> I get a decimal point after each number, even if there is no fractional
> part. If I don't I risk getting rationals (1/2). What is the preferred
> solution?
>
> I guess I could either convert everything to reals (using N[]) and
> change the printed representation (but I couldn't find out how to get
> rid of the decimal point reading the manuals), or try to stick with
> precise numbers and only convert if fractions result. Is there a way to
> do that?
>
> --J.
>
>
- References:
- Decimal point in printed numbers
- From: Jan Rychter <jan@rychter.com>
- Decimal point in printed numbers