How do I change axes scale in a surface plot by a predefined factor?
70 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Iron1759
am 3 Jan. 2021
Beantwortet: Iron1759
am 14 Jan. 2021
Hello,
I have a surface plot -
on x axis - [0,1,2.... 15];
on y axis - [0,1,2,...50];
I'd like to change the axes scale by multiply these two vector by a factor (different one on each axis), for exmaple by 12.5578 and thus changing only the axes lables.
I'm familair with XtickLabel and YTickLabel but I think it's less applicatble, mainly becaue this factor is not round.
Real life example - for instance when you want to change reperesntation from pixles to real units without changing the data.
Any thoughts?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Mischa Kim
am 3 Jan. 2021
Iron, if it just about changing the labels simply use xticklabels(). See the example below:
x = linspace(-10,10,200);
y = cos(x);
plot(x,y)
xticklocs = [-3*pi -2*pi -pi 0 pi 2*pi 3*pi];
xticks(xticklocs);
myfac = 10; % this would be your 12.5578
xticklabels(cellstr(num2str(xticklocs'*myfac)));
4 Kommentare
Mischa Kim
am 10 Jan. 2021
See this example:
x = linspace(-10,10,200);
y = cos(x);
figure(1)
plot(x,y)
xticklocs = [-3*pi -2*pi -pi 0 pi 2*pi 3*pi];
xticks(xticklocs);
figure(2)
plot(x,y)
xticklocs = -400:80:400; % these are the nice numbers
myfac = 400/(3*pi);
xticklabels(cellstr(num2str(xticklocs.')));
xticks(xticklocs/myfac);
If this does not help, share your code so I can provide specific input.
Siehe auch
Kategorien
Mehr zu Axis Labels 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!