How to set the range of X axis equal to a column vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I want to creat a plot with two x axis (first one in the bottom and second one in the top) . I want to set the range of the seconde axis equal to a column array (x2) (the first point in the x xis = first element in x2). I write the following code;
However, the result plot is not what I need ( I want the second axis starts from the first element of x2 but it starts from the last elemnts). Furtheremore, I don't need the second y axis. How should I correct my code in order to get the result that I want.
I have attached the data for x2 and the result plot
Thanks for you help,
figure
line (X, Y)
ax1 = gca; % current axes
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','non');
line(x2,ax2,'Color','r')
0 commentaires
Réponse acceptée
Jan
le 16 Jan 2019
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'XLim', [0.8, 1.35], ...
'XDir', 'reverse', ...
'YTick', [], ... % No ticks on Y axis
'Color','non');
Or set the XTick and XTickLabel manually.
2 commentaires
Jan
le 16 Jan 2019
I do not understand what "set one y value to 2 x value" means. "x1=number of cycle and x2=time" is not clear also: What is "number of cycle"? What do you want to show in one plot? In "y=i", what is "i"? Where do you "specify the corresponding cycle and time"?
I do not understand, which problem you want to solve. Please post a small example with inputs and explain the wanted output.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Formatting and Annotation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!