Clear Filters
Clear Filters

change axis range but not the graph in 3d plot

1 view (last 30 days)
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,

Answers (1)

José-Luis
José-Luis on 17 Sep 2012
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 Comments
Florian
Florian on 17 Sep 2012
Edited: Florian on 17 Sep 2012
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 on 17 Sep 2012
Edited: José-Luis on 18 Sep 2012
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.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!