set x-axis intervals as cubic of X

3 vues (au cours des 30 derniers jours)
laurent jalabert
laurent jalabert le 21 Mai 2019
hello,
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);
errorbar(x,y1,err_y1,'-v','Color',markerColour,'MarkerEdgeColor',markerColour,'MarkerFaceColor',markerColour);
title(strcat(YLABEL_M{u(idx(IndexT))},'= ',num2str(Pp{IndexT}(i),'%.0f')),'FontSize',12); % title of the overall graph
set(gca,'Xscale','lin','Yscale','lin','FontSize',16);
grid on; hold on;

Réponses (1)

laurent jalabert
laurent jalabert le 22 Mai 2019
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,

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by