Linkprop breaks down with "go to xy view"

2 次查看(过去 30 天)
So i have two axes which i am using to display a modified colorbar for my figure (essentially i have painted one color as a 'faux' color where there is no data and don't want that on the colorbar. i used 'linkprop' to link the axes and all is well - except if i press the "goto x-y view" option in the right mouse click of the rotate button. Then the axes are offset.
my linkprop line is:
linkprop([handles.axes1,handles.axes2],{'Position','CameraPosition','CameraUpVector','Position','PlotBoxAspectRatio'})
but i get the following if i print out the 'axes' after "goto xy view"
Axes with properties:
XLim: [-0.1000 0.1000]
YLim: [-0.1500 0.2000]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.0397 0.1009 0.5080 0.7301]
Units: 'normalized'
Show all properties
ans =
Axes with properties:
XLim: [0 1]
YLim: [0 1]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.0397 0.1009 0.4857 0.7301]
Units: 'normalized'
so clearly position is not 100% linked here.. any suggestions?
  4 个评论
Jason Riley
Jason Riley 2017-8-3
编辑:Jan 2017-8-3
Jan, the 'why' is a colorbar issue. (i want to display one colormap but use a colorbar with a modified colormap).
essentially the phenomenon can be recreated easily by the following code:
data = rand(4,5);
tris = [[1 2 3];[2 3 4];[4 5 3]];
axes1=axes;
trisurf(tris,data(1,:),data(2,:),data(3,:),data(4,:));
axes2 = axes;
%% Link them together
%linkaxes([handles.axes1,handles.axes2])
linkprop([axes1,axes2],{'Position','CameraPosition','CameraUpVector','Position','PlotBoxAspectRatio'})
%% Hide the top axes
axes2.Visible = 'off';
axes2.XTick = [];
axes2.YTick = [];
handles.axes2.PickableParts = 'none';
handles.axes2.HitTest='off';
%% Give each one its own colormap
jet2=colormap('jet');
jet2(1,1)=1;
jet2(1,2)=1;
jet2(1,3)=1;
colormap(axes1,jet2)
colormap(axes2,'jet')
%% Then add colorbars and get everything lined up
cb2 = colorbar(axes2);
caxis(axes2,[0.78, 1.6]);
cb1 = colorbar(axes1);
caxis(axes1,[0.78, 1.6]);
After this you can rotate the image merrily, until you right click and hit "goto xy view", then it screws up.. its more dramatic in this example than my other code, which maybe as the other one is sitting inside a Guide GUI - but the principle is the same, it appears that somehow the goto xy view code is different from the goto xz or goto yz code....
Jan
Jan 2017-8-3
编辑:Jan 2017-8-3
@Jason: Do you know the "{} Code" button to format code? This will look nicer than inserting a blank line after each line.
Yes, now I see it in R2016b.
I would prefer a cheap solution: Use one colormap in a single axes object, and draw another colorbar, in case of troubles manually. Look in the code of colorbar.m to see, how this works. It is not worth to struggle with two axes and linked properties.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by