set x-axis intervals as cubic of X

2 ビュー (過去 30 日間)
laurent jalabert
laurent jalabert 2019 年 5 月 21 日
回答済み: laurent jalabert 2019 年 5 月 22 日
I am really sorry to bother you all with this question, I know that there is a solution somewhere in a forum (yesterday I found it, but I cannot find it again today, maybe because my keywords are not appropriated).
I am plotting subplots of errobar graphs, displaying X and Y experimental data. The x-axis interval is linear. I would like to set the x-axis interval as X^3, keeping the xlabel as X, and displaying the xticks as X^3.
Actually, I use set(gca,'Xscale','lin','Yscale','lin','FontSize',16);
I want to modify this line to display Xscale with XTicks as X^3
Could someone refresh my mind ?
Just to figure out some line of my program (for reading only) :
long = 800; large = 800;
f1 = figure('PaperUnits','inches','PaperType','A4','PaperOrientation','landscape',...
'Color',[1 1 1], 'OuterPosition',[20 1 long large]);
set(0, 'CurrentFigure', f1);
title(strcat(YLABEL_M{u(idx(IndexT))},'= ',num2str(Pp{IndexT}(i),'%.0f')),'FontSize',12); % title of the overall graph
grid on; hold on;

回答 (1 件)

laurent jalabert
laurent jalabert 2019 年 5 月 22 日
x = 0:9 ; y = 2+3.*x; figure; plot(x,y);
xt = get(gca, 'XTick ');
xtlc = sprintfc('%.1f', xt.^3 );
set(gca, 'XTick', xt, 'XTickLabel',xtlc)
This is your code. I added a " . " because it ia vector (y = 2+3.*x). Anyway.
When I run this code, thre is an error.
Next : of course I can take (0:9).^3 as you mentionned but this is not my question.
I realize that the formulation of my question is misleading because you could not understand clearly what I intend to do. So I am very sorry for that.
My question is related to the grid of the X-axis that I would like to be as cubic intervals on the graph (similarly as log scale). If I apply your method, I get a fixed interval on X-axis. Anyway. Thank you again for your time,





Community Treasure Hunt

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

Start Hunting!

Translated by