Consider :
Grid@Partition[
Text[Style[ToString[Range[0, 180, 22.5][[#]]] <> "\[Degree]", Bold, 16,
GrayLevel[(8 - #)/10]]] & /@ Range[8], 2, 1]
How can I get rid of the dot following the Integers ?
If a number becomes an integer when you rationalize it, use the integer; otherwise stick with the original number. This is achieved by a simple function, f[x]
:
f[x_] := If[IntegerQ[n = Rationalize[x]], n, x]
Testing...
f[67.5]
f[0.]
f[45.]
(* Out *)
67.5
0
45
You can't just Rationalize
all the values, as the following makes clear:
To see how it works in your case, just insert (f/@)
into your code to reformat the values output from Range
:
Grid@Partition[
Text[Style[
ToString[(f/@ Range[0, 180, 22.5])[[#]]] <> "\[Degree]",
Bold, 16, GrayLevel[(8 - #)/10]]] & /@ Range[8], 2, 1]
So
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With