3
$\begingroup$

I have a grid of images and I' d like to add axes with labels for the \ two dimensions. Here's my data:

g = Grid@Table[RandomImage[1, {50, 50}], {i, 5}, {j, 10}];

Now I'd like to show with ticks how the x and y axes are increasing. To say the lease, this doesn't do the trick:

Labeled[g, {Column[{"Y axis", Graphics[Arrow[{{0, 0}, {1, 0}}]]}], 
  Column[{Graphics[Arrow[{{0, 0}, {0, 1}}]], "X axis"}]}, {Left, 
  Bottom}, RotateLabel -> True]
$\endgroup$

1 Answer 1

5
$\begingroup$

Second try

Now with better spacing for the axis lines.

Based on the comments I think this may work for you.

imgs = Table[RandomImage[1, {50, 50}], {i, 4}, {j, 7}];
imgs = Transpose @ imgs;

Graphics[
  MapIndexed[Inset[Rasterize@#, #2] &, imgs, {2}] 
  , PlotRange -> Thread[{1/4, 2/3 + Dimensions @ imgs}]
  , Axes -> True
  , Ticks -> Range @ Dimensions @ imgs
  , AxesStyle -> Arrowheads[0.03]
  , AxesOrigin -> {1/4, 1/4}
  , ImageSize -> 420
];

Labeled[%, {"Y axis", "X axis"}, {Left, Bottom}, RotateLabel -> True]

enter image description here

Note:

  • The individual images are fixed size and their spacing is determined by the overall ImageSize. They will overlap if the ImageSize is small.
$\endgroup$
11
  • $\begingroup$ Nice, but could you make the axes go all the way across and put ticks on the lines at the centers of the images with specific values? $\endgroup$
    – user5601
    Commented Jul 14, 2016 at 1:49
  • $\begingroup$ Kind of like MatrixPlot[{{1, 2, 1}, {3, 0, 1}, {0, 0, -1}}, FrameTicks -> {{True, False}, {True, False}}] but with the grid instead of the matrix $\endgroup$
    – user5601
    Commented Jul 14, 2016 at 1:51
  • $\begingroup$ @user5601 Do the items in your grid need to be absolute size (one to one pixel) or is it OK if they are scaled somewhat? It may be practical to Inset them into a plot with ticks. $\endgroup$
    – Mr.Wizard
    Commented Jul 14, 2016 at 1:54
  • $\begingroup$ It's always nice to Have PixelContrained->1, but that should be fine $\endgroup$
    – user5601
    Commented Jul 14, 2016 at 2:05
  • $\begingroup$ @user5601 Please see my updated answer. $\endgroup$
    – Mr.Wizard
    Commented Jul 14, 2016 at 2:32

Your Answer

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

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