4
$\begingroup$

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}]
$\endgroup$
5
  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/a/4721/5 $\endgroup$
    – rm -rf
    Oct 17, 2012 at 18:01
  • $\begingroup$ You need to remove PlotRange -> {{0., 1.}, {0., 1.}}. $\endgroup$
    – kglr
    Oct 17, 2012 at 18:14
  • $\begingroup$ ... 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 $\endgroup$
    – kglr
    Oct 17, 2012 at 18:55
  • $\begingroup$ @kguler Probably a typo (.1 instead of 1), it should be PlotRange -> {All, All, {0, 1}} $\endgroup$
    – VLC
    Oct 17, 2012 at 19:35
  • $\begingroup$ @VLC, right ... meant {0.,1.}:) $\endgroup$
    – kglr
    Oct 17, 2012 at 20:00

1 Answer 1

6
$\begingroup$

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

$\endgroup$
8
  • $\begingroup$ But where is the gradient!? $\endgroup$ Oct 17, 2012 at 18:05
  • $\begingroup$ There should be a vertical rainbow gradient $\endgroup$ Oct 17, 2012 at 18:13
  • $\begingroup$ @TomWellington Your plot didn't produce any either, so I was dealing with FrameTicks only. $\endgroup$
    – VLC
    Oct 17, 2012 at 18:14
  • $\begingroup$ @TomWellington See update for the gradient. $\endgroup$
    – VLC
    Oct 17, 2012 at 18:23
  • $\begingroup$ Change {0,75} to {1,75} to get the first tick. $\endgroup$
    – kglr
    Oct 17, 2012 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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