Error on 'axes' parameters
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Vasileios Leivadas
el 12 de Jul. de 2018
I am receiving the following error probably referring to 'XLim' or 'YLim' as 'axes' parameters:
Error using axes
Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf
I checked my workspace and everything seems fine since 'XLim' is a 1x2 datetime vector and 'YLim' is a 1x2 numeric vector with their 'min limit' < 'max limit'.
The related code is the following:
ax1 = gca;
ax1_Pos = ax1.Position;
ax1_XLim = ax1.XLim;
ax1_YLim = ax1.YLim;
ax1_start = ax1.XLim(1);
%ax1_end = ax1.XLim(2);
xticks([ax1_start, time_dat(51-1), time_dat(86-1), time_dat(129-1), time_dat(170-1)]);
ax2_labels = {'z_acc_test','setup1','y_acc_test','setup2','x_acc_test'};
ax2 = axes('Position', ax1_Pos, 'XLim', ax1_XLim, 'YLim', ax1_YLim, 'XAxisLocation', 'top', 'YAxisLocation', 'right', 'XTick', xticks, 'XTickLabel', ax2_labels);
0 comentarios
Respuesta aceptada
Adam Danz
el 12 de Jul. de 2018
Editada: Adam Danz
el 12 de Jul. de 2018
In the last line of your code, what does 'xticks' equal? I see you use the function xticks() but I don't see where you have assigned a value to a variable 'xticks'. Could your error be due to that?
11 comentarios
Adam Danz
el 13 de Jul. de 2018
Editada: Adam Danz
el 13 de Jul. de 2018
Those dates work for me and I don't have any errors. In this example I set the datetime limits to your date/times above.
figure
ax1 = axes;
ax1_XLim = datetime([2018,2018],[7,7],[11,11],[15,16],[52,01],[0,0]);
xl = datenum(ax1_XLim);
xlim(xl)
set(ax1, 'xtick', xl)
datetick(ax1, 'x', 'mmm dd, yyyy, HH:MM', 'keepticks')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192061/image.jpeg)
Más respuestas (1)
Vasileios Leivadas
el 13 de Jul. de 2018
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!