Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

For some reason the ticks don't work on this:

ArrayPlot[Thread@{Range[0, 1, 0.01]}, AspectRatio -> 4, 
 ColorFunction -> "Rainbow",
 PlotRange -> {{0.`, 1.`}, {0.`, 1.`}},
 FrameTicks -> {{None, {{0, 75}, {1/5, 100}, {2/5, 125}, {3/5, 
      150}, {4/5, 175}, {1, 200}}}, {None, None}},
 Frame -> True,
 PlotRangePadding -> 0,
 BaseStyle -> 
  Directive[Opacity[1], FontFamily -> "Bitstream Charter", 10],
 ImageSize -> {Automatic, 100}]
share|improve this question
1  
Related: mathematica.stackexchange.com/a/4721/5 –  rm -rf Oct 17 '12 at 18:01
    
You need to remove PlotRange -> {{0., 1.}, {0., 1.}}. –  kguler Oct 17 '12 at 18:14
    
... interestingly, the way PlotRange works inside ArrayPlot and MatrixPlot is quite different from what we have come to expect based on standard usage patterns inside other Graphics objects. So, instead of removing PlotRange you can also use PlotRange->{All,All,{0.,.1}}. See other interesting examples in the ArrayPlot>>Options>>PlotRange –  kguler Oct 17 '12 at 18:55
    
@kguler Probably a typo (.1 instead of 1), it should be PlotRange -> {All, All, {0, 1}} –  VLC Oct 17 '12 at 19:35
    
@VLC, right ... meant {0.,1.}:) –  kguler Oct 17 '12 at 20:00
add comment

1 Answer

up vote 6 down vote accepted

I think that your problem is related to the fact that your array is actually a vector. If you use Automatic in FrameTicks you get this:

ArrayPlot

But you can apply this workaround:

ArrayPlot[Thread@{Range[0, 1, 0.01]}, AspectRatio -> 4, 
 ColorFunction -> "Rainbow", PlotRange -> {{0.`, 1.`}, {0.`, 1.`}}, 
 FrameTicks -> {{None, {{.5, 75}, {.7, 100}, {.9, 125}, {1.1, 150}, {1.3, 175}, 
 {1.5, 200}}}, {None, None}}, Frame -> True, 
 PlotRangePadding -> 0, 
 BaseStyle -> 
  Directive[Opacity[1], FontFamily -> "Bitstream Charter", 10], 
 ImageSize -> {Automatic, 100}]

ArrayPlot

Update

To get your gradient you have to remove the PlotRange and then specify a new set of ticks.

ArrayPlot[Thread@{Range[0, 1, 0.01]}, AspectRatio -> 4, 
 ColorFunction -> "Rainbow", 
 FrameTicks -> {{None, {{1, 75}, {20, 100}, {40, 125}, {60, 150}, {80,
       175}, {100, 200}}}, {None, None}}, Frame -> True, 
 PlotRangePadding -> 0, 
 BaseStyle -> 
  Directive[Opacity[1], FontFamily -> "Bitstream Charter", 10], 
 ImageSize -> {Automatic, 100}]

ArrayPlot with gradient

share|improve this answer
    
But where is the gradient!? –  Tom Wellington Oct 17 '12 at 18:05
    
There should be a vertical rainbow gradient –  Tom Wellington Oct 17 '12 at 18:13
    
@TomWellington Your plot didn't produce any either, so I was dealing with FrameTicks only. –  VLC Oct 17 '12 at 18:14
    
@TomWellington See update for the gradient. –  VLC Oct 17 '12 at 18:23
    
Change {0,75} to {1,75} to get the first tick. –  kguler Oct 17 '12 at 18:29
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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