reve_etrange
reve_etrange

Reputation: 2571

Display image at desired scale across subplot axes

Is it possible to display an image in multiple subplot axes, such that the image appears at the desired scale?

subplot(3,3,[1 4 7]);
%# image scaled down to fit 1 set of axes
imshow(img);
subplot(3,3,2);
plot(relevantData);
%# And so on with 5 other plots

I want to have the image scaled to either a fixed size or to fit the axes available to it, rather than to the size of a single axes.

My use case is to show a video alongside plots derived from the video, such that the plots are progressively drawn in step with the video. Once the display is correct I can save each image and combine them into a video.

Clarification

I am asking if it is possible to produce a figure as described without specifying the position of every element in absolute terms. Though one can make arbitrary figures that way (and in fact I have done so for this project), it is very tedious.

Upvotes: 1

Views: 3152

Answers (1)

jpjacobs
jpjacobs

Reputation: 9559

Edit:

For changing the size of the subplot:

In help subplot they mention that you can set parameters on the selected "axes" (that's what they call a plotting area in Matlab).

Using that, you can set the 'position', as seen in help axes. This property takes takes as argument:

[left, bottom, width, height]

As pointed out by @reve_etrange, one should use absolute positioning for axes 'Position'and 'OuterPosition' parameters. they can be in normalized coordinates, though.

For changing the size of the image in the subplot:

I think there are 2 useful things for you in the help imshow output:

  1. 'InitialMagnification': setting the magnification of the image.
  2. 'Parent': determines which parent imshow will use to put the image in (never tried using imshow with subplots).

Upvotes: 2

Related Questions