I am building a demonstration application using the matlab application designer. It has two axes. One shows an image. The other shows the profile of the image, and the derivative of the profile.
In the example below, I have a 200 column, by 5 row image.
Below the image, I have a plot of the image profile, and a plot of the derivative. The image profile has (not surprisingly) 200 elements. I'd like the X/Y plots to align consistently with the image axis.
Is there a way to control the image axes, to align correctly with the plot axes?
Obviously, I could remove the axis(app.AxesImageView,'off') line below, and force the axes on. But, that doesn't work either, because the axis labels are very different, and so they don't line up. I want this to be flexible to work for any size image, and the label sizes impact this as well.
TLDR: Is it possible to force the axes in a plot or an imagesc to reside in a particular spot in the region the axes have set aside for rendering?
The current code for rendering the image and the plot are:
w = 5; l = 200;
parms.filterHalfWidth = 20;
img = zeros(w,l);
img(:,ceil(l/2):end)=255;
img = uint8(img);
imagesc(app.AxesImageView,img,[0,255]);
colormap(app.AxesImageView, 'gray');
axis(app.AxesImageView,'off');
title(app.AxesImageView,'Image to find edge');
profile = mean(img,2);
vals = derivative(profile, parms.filterHalfWidth);
[~, peak] = max(vals);
plot(app.AxesProfiles, profile);
hold(app.AxesProfiles, 'all');
plot(app.AxesProfiles, parms.filterHalfWidth + (1:numel(vals)), vals);
plot(app.AxesProfiles, peak*[1,1], [0,255],'Color','Red','LineWidth',2);
hold(app.AxesProfiles, 'off');