change axis range but not the graph in 3d plot

1 次查看(过去 30 天)
Hello all,
Please try this
GG2 =rand(109,512);
figure43 = figure(43);
surf(GG2)
figure44 = figure(44);
x = linspace (20,200,2);
surf(x,GG2(:,1),GG2);
I do want the same graph than in figure43 but the x-axis range should go from 20 to 200 and not from 0 to 600.
The figure44 shows nothing...
Is this possible somehow?
Regards,

回答(1 个)

José-Luis
José-Luis 2012-9-17
Is it not just a matter of setting the axes limits to [0 200]?
GG2 =rand(109,512);
figure43 = figure(43);
h = surf(GG2)
aH = ancestor(h,'axes')
set(aH,'XLim',[20 200])
  2 个评论
Florian
Florian 2012-9-17
编辑:Florian 2012-9-17
I am afraid not because xlim([20 200]) just cuts off the rest of the graph. I want the whole graph displayed just like before but with another axis range (20-200)
José-Luis
José-Luis 2012-9-17
编辑:José-Luis 2012-9-18
The easiest way would be to set the ticks to the range 20-200 instead, for example:
set(aH,'XTick',20:20:200)
If you want the axes to go only from 20 to 200, then it is not trivial. You could copy the axes and make the original axes invisible ('Visible','off') and set the position of the new axes so they correspond to [20 200]. The difficulty of that approach is that the axes position is defined with respect to the figure box, not to the plot coordinates. You would need to transform between one and the other, i.e. if you rotate your plot you would need to recalculate everything.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by