Save Axis Labels/Titles/Ticks for Iterative Plotting

I have two different surfaces to plot, under mildly different model assumptions. I go through a lot of trouble modifying the axis ticks, labels, title etc for the first surface. The majority of these are the same for the second surface, only the title will be different. Unfortunately when I replot the second set of data, all my work has disappeared! I need to go through all the axis labels, ticks etc. a second time. Is there a way to save all that info for iterative plotting?
Thanks.

 採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 9 日

0 投票

If you have set the XTick or YTick property yourself, such as via set(), then the ticks will be retained when the data changes. More specifically, if you set() the XTick or YTick properties then the respective *TickMode property is set to 'manual', and when that property is 'manual' then ticks will not be recalculated.
The ticks and titles are part of the axes, so you can copyobj() the axes, set() it's Position if you need to, and set() the child surface's XData, YData, ZData (and perhaps CData) to the new data. If you took a bunch of trouble setting up the ticks on the first one, then the 'manual' property of the tick mode should be copied.
And if not... you can always set() the XTick or YTick properties of the new axes to the get() of the appropriate *Tick properties of the first axes.

1 件のコメント

Erez
Erez 2011 年 10 月 9 日
Great, thanks. If its not too much trouble, could you provide a quick example? This get/set and children and parents and adoption is a bit confusing. Thanks in advance and in the present.

サインインしてコメントする。

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 10 月 9 日

0 投票

use hold on before the second plot. help hold
use copyobj()
Or maybe this is what you need. Note that changing the 'xdata','ydata' will automatically change the axis ticks and axle limit.
f1=figure(1);
p=plot(1:10);
title('first');
xlabel('x');
ylabel('y')
set(p,'xdata',1:100,'ydata',rand(100,1));

4 件のコメント

Dr. Seis
Dr. Seis 2011 年 10 月 9 日
Won't that also hold the first surface? It sounds like this person would like to keep all the settings the same, just change the surface. Erez, is this right?
Fangjun Jiang
Fangjun Jiang 2011 年 10 月 9 日
Good point. I think you are right. Then I think you need to use copyobj().
Fangjun Jiang
Fangjun Jiang 2011 年 10 月 9 日
See updated answer to see if that provides a solution.
Erez
Erez 2011 年 10 月 9 日
Hey, this solution is good, but one of my main frustrations is ticks. I hate changing ticks over and over again...There must be another way to do this.

サインインしてコメントする。

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by