Positioning bar and image in the same figure
Show older comments
I'm trying to print an image above a bar plot in the same figure, manually changing their position using the set command with the OuterPosition option.
This works only if the vertical coordinate of the image is at least 0.42, in fact if it is below this value then the image disappears.
How can I place the image below 0.42?
subplot(2,1,1)
imshow( imread('https://i.imgur.com/TVlQhpj.jpg') )
set(gca, 'OuterPosition', [.3 .42 .4 .4]);
subplot(2,1,2)
bar(1:10)
set(gca, 'OuterPosition', [.3 0 .35 .23]);

4 Comments
Rik
on 1 May 2020
Why are you using the OuterPosition property? Is there a particular reason you aren't using the Position property?
giannit
on 1 May 2020
Rik
on 1 May 2020
I tend to use the Position property. Also, you can store the handle generated by subplot, so you can avoid gca. You can also directly create the axes in the position you want it with the axes function.
giannit
on 1 May 2020
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!