Filter löschen
Filter löschen

Changing the axis property of matlab

1 Ansicht (letzte 30 Tage)
Ede gerlderlands
Ede gerlderlands am 18 Feb. 2013
I have the already plotted matlab figure and I want to change the x-axis value of the plot. I intend to multiply the old x -value by 1000 to get the new x which has to be shown in graph.
Can somebody help me with that?
Thanks

Akzeptierte Antwort

José-Luis
José-Luis am 18 Feb. 2013
Bearbeitet: José-Luis am 18 Feb. 2013
h = plot(rand(10,1));
aH = ancestor(h,'axes');
x = get(h,'XData');
new_x = x .* 1000;
new_y = get(h,'Ydata');
delete(h);
plot(aH,new_x,new_y);
Alternatively, you could only change the XTickLabel:
h = plot(rand(10,1));
aH = ancestor(h,'axes');
x = get(aH,'XTick');
set(aH,'XTickLabel',sprintf('%d |',x.*1000));
  3 Kommentare
José-Luis
José-Luis am 18 Feb. 2013
Please see edited answer.
Ede gerlderlands
Ede gerlderlands am 18 Feb. 2013
Thank you..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by