There seems to weird bug regarding non-integer PlotRange
in ArrayPlot
. For example...
ArrayPlot[
Table[Sin[x/50 π] Tanh[y/50 π], {y, 100}, {x, 100}],
DataRange -> {{0, 1}, {0, 1}},
PlotRange -> {{0, 1}, {0.5, .9}}
]
gives an error:
Value of option PlotRange -> {{0,1},{0.5,0.9}} is not All, Full, Automatic, a positive machine number, or an appropriate list of range specifications.
The same code works, if one of the plot range parameters for y-axes is turned into an integer.
Did I do smth wrong? Is there a workaround?
I need to use array plot as ListContourPlot
is too slow for large datasets and MatrixPlot
has the same problem.
I am using Mathematica 8 64 bit version on linux.
Edit
After some more testing I see, that it works whenever PlotRange includes at least one integer. For example PlotRange -> {{0, 1}, {0.5, 1.2}}
works as it includes 1. So one possible workaround is just to scale the range, such that max-min would be larger than 1.
But I am still looking forward, if anyone finds a way to have shorter than 1 range on the axes. Dirty way would be just using manual 'Ticks'.
Edit 2
Possible workaround.
As I wrote in the previous edit, it works, then the range includes at least one integer. So one could just scale the range. Here is a naive hard-coded example how it might be done.
ArrayPlot[
Table[Sin[x/50 π] Tanh[y/50 π], {y, 100}, {x, 100}],
DataRange -> {{0, 1}, {0, 1} 10},
PlotRange -> {{0, 1}, {0.1, 0.8} 10},
FrameTicks -> {Table[{y, ToString[y/10 // N]}, {y, 1, 8, 1}],
Table[{x, ToString[x // N]}, {x, 0, 1, 0.25}]},
AspectRatio -> 1
]
This means that I have bypassed the only side-effect of scaling the range, which is messing up the tick labels.
I would submit it as a solution, when I have waited my 8 hours and there is no nicer one proposed.
Answer
Here is a workaround that works in V7,8,9,10 (the underlying problem persists):
Show[
ArrayPlot[
Table[Sin[x/50 π] Tanh[y/50 π], {y, 100}, {x, 100}],
DataRange -> {{0, 1}, {0, 1}}],
PlotRange -> {{0, 1}, {0.5, .9}}, FrameTicks -> All]
Comments
Post a Comment