Setting Subplot Axes with Alpha Hull
Show older comments
I wish to create a window with 2 sub-plots. In each of these subplots will be a number of Alpha Hulls. For clarity of display I need to set the x and y axis of the subplots, usually to the same scale. However, when setting the axis the plot appears in a 'letterbox' style and does not rescale to fill the window. When using other shapes it does.
I have illustrated this with the code below which is simplified from the code I am using.
In the left subplot I create a shape, set the transparency and resize the axis, the subplot keeps the full window height.
In the right subplot I draw an Alpha Hull set the transparency and rescale the axis exactly the same way, but instead of showing the full height plot we get a 'letterbox' type diplay with the top and bottom of the plot cut off.
You can exchange the remmed lines of code to swap it from left to right.
What is different about the Alpha Plot that prevents the axis rescaling the same and how do I get around it?
Thanks in advance,
Rich
%%Set variable
xp=[0.25; 0.25; 0.75; 0.75];
yp=[0.25; 0.5; 0.5; 0.25];
scnsize = get(0,'ScreenSize');
%%create figure and position
fig = figure(3);
XLims=[0 20];
YLims=[-2 2];
PlotNorm=subplot(1,2,1);
cla
PlotAbnorm=subplot(1,2,2);
cla
pos3 = [0, 0, scnsize(3), scnsize(4)/2];
set(fig,'OuterPosition',pos3)
%%create Alpha Hull
HullRes=0.5;
HullPoints=[xp,yp];
AlphaHull=alphaShape(HullPoints,HullRes);
%%Plot
subplot(PlotNorm);
% AH=plot(AlphaHull,'FaceColor','r','LineStyle','none');
AH=fill(xp,yp,'r');
set(AH,'FaceAlpha',0.2);
set(gca,'XLim',XLims);
set(gca,'YLim',YLims);
hold on
subplot(PlotAbnorm);
AH=plot(AlphaHull,'FaceColor','r','LineStyle','none');
% AH=fill(xp+0.25,yp-0.25,'r');
set(AH,'FaceAlpha',0.2);
set(gca,'XLim',XLims);
set(gca,'YLim',YLims);
hold on
Accepted Answer
More Answers (0)
Categories
Find more on Bounding Regions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!