Linkprop breaks down with "go to xy view"

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 Commenti

I also notice that if i start from original position and rotate to each of xy, yz and xz view that something interesting happens. for the other two (yz and xz) if i rotate to position and then click "view" nothing happens - but with 'xy view' when i rotate to that position and then click it, the figure zooms in a fraction - this is probably where that z offset is arising - how do i fix that?
I cannot follow you. Why do you create two axes at the same position? Why do you want to link the position property? Do you move the axes manually? What is the connection to the colorbar? Can you post some code which replicates the problem?
Jason Riley
Jason Riley il 3 Ago 2017
Modificato: Jan il 3 Ago 2017
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 il 3 Ago 2017
Modificato: Jan il 3 Ago 2017
@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.

Accedi per commentare.

Risposte (0)

Categorie

Prodotti

Richiesto:

il 3 Ago 2017

Modificato:

Jan
il 3 Ago 2017

Community Treasure Hunt

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

Start Hunting!

Translated by