How to set the range of X axis equal to a column vector

10 visualizaciones (últimos 30 días)
Sara
Sara el 16 de En. de 2019
Comentada: Jan el 16 de En. de 2019
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,plot.jpg
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')

Respuesta aceptada

Jan
Jan el 16 de En. de 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 comentarios
Sara
Sara el 16 de En. de 2019
Thanks for yor answer, the plot is what I need, However, I think I've described my question wrongly,
I need to set one y value to 2 x value (x1=number of cycle and x2=time) and show it in one plot. for example when y= i I can specify the corresponding cycle and time (x1 and x2). How can I do it.
Jan
Jan el 16 de En. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by