0
$\begingroup$

When I specify tick marks in ArrayPlot I want to keep the number of trailing zero's that I specify. One work around is to use a label for that tick mark (i.e. Ticks->{0.8,0.9,{1.0,"1.0"},1.1,1.2}), but is there a neater solution to save me doing this manually?

For example if I generate a plot with the code

legend = {0.9996 + 0.0001 #, 0.9996 + 0.0001 #} & /@ {0, 1, 2, 3, 4, 5, 6, 7, 8};
ArrayPlot[legend, ColorFunction -> "ThermometerColors", 
 DataRange -> {{0, 1}, {0.9996, 1.0004}}, 
 FrameTicks -> {{0.9996, 0.9997, 0.9998, 0.9999, 1.0000, 1.0001, 
    1.0002, 1.0003, 1.0004}, None}, AspectRatio -> 7, 
 LabelStyle -> Large]

which gives me

enter image description here

we see the "1." looks out of place as it is.

$\endgroup$
  • 3
    $\begingroup$ There are a number of ways to set how a number is displayed: NumberForm, PaddedForm, SetPrecision. You could Map one of these over your ticks: {#, NumberForm[#, {5, 4}]}&/@ ticks. $\endgroup$ – wxffles Oct 29 '14 at 2:10
  • $\begingroup$ @wxffles You seem to have beat me too it. :( $\endgroup$ – Edmund Oct 29 '14 at 2:19
  • $\begingroup$ Proposed duplicate: (22722) or (33297). $\endgroup$ – Mr.Wizard Oct 29 '14 at 10:00
  • 1
    $\begingroup$ Related: (3436), (5276), (5369), (8791), (8923), (23763), (39247) $\endgroup$ – Mr.Wizard Oct 29 '14 at 10:01
5
$\begingroup$

Use a function with NumberForm to construct your FrameTicks.

FrameTicks -> {{#, NumberForm[#, {5, 4}]} & /@ legend[[All, 1]], None}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.