Aligning subplots (width) in a figure
Afficher commentaires plus anciens
Hello, I'm having trouble having my subplots align (width). Any ideas?
%%Graphing Fluorescent Intensity
clc;
clear all;
close all;
fontSize = 16;
%
% Calculate the mean gray level.
grayImage = imread('alignedImage.png');
meanAlongEachColumn = mean(grayImage);
%
% Plot the aligned image
h=figure;
subplot(2,1,1);
alignedplot = subplot(2,1,1);
imshow('alignedImage.png');
axis on;
title('Aligned Image', 'FontSize', fontSize);
%
% Plot the Fluorsecent Intensity
subplot(2,1,2);
fluorplot = subplot(2,1,2);
plot(meanAlongEachColumn, 'k-', 'LineWidth', 2);
title('Fluorescent Intensity', 'FontSize', fontSize);
xlabel('Position');
ylabel('Fluorescent Intensity');
%
% Find current position [x,y,width,height]
pos1 = get(alignplot, 'Position');
pos2 = get(fluorplot, 'Position');
%
% Set width of second axes equal to first
pos2(3) = pos1(3);
set(alignplot,'Position',pos2)

Réponse acceptée
Plus de réponses (1)
Alonso Trejo-Mora
le 31 Juil 2018
Just in case others come across my version of this issue (which seems to be identical to this one), the fix is actually much simpler than this. On the subfigure containing the image, use the command
axis normal;
My image was previously set to "axis image" which made manual adjustment very annoying until I figured this out. I also encourage others to use the computer mouse symbol in every figure's toolbar and click away at some options. There's a lot you can play with and many properties you might not know existed.
Catégories
En savoir plus sur Blocked Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!