Switching to datetime / numeric axis and returning datetime data points

2 次查看(过去 30 天)
Dear all,
I have an interface in which a user can graph data. Since I'm working with timetables, when using 'Time' (datetime variable) as X-variable, the axis ruler style automatically changes to a DatetimeRuler. However, in some cases it is preferable to use another (numeric) variable for the X-axis. The problem I face is that after having used the datetime variable 'Time' it does not seem possible to change back to a numericRuler. I've come across several posts on the topic (including this one) but so far I'm unable to revert the axis back to a numeric, and having to close the program and load all data again clearly is undesirable. By the way, I'm not using the 'hold on' function during all this.
Additionally, in the same program I use datacursormode to 'getCursorInfo' to return the datatip information, see e.g. the figure below. The Position result from these data points is:
[0.396209722222222, 100.120000000000]
[0.431294560315167, 20.0400000000000]
[0.458508101851852, 99.9600000000000]
of which the X-data can be converted to a string using datestr, but in this case the date-information is gone (e.g. " ans = '11:00 AM' "). I would have expected an absolute Matlab time value such as "7.375584585081019e+05" or comparable. When using data which covers more than one day the results get even less logical. Though there is also a 'DataIndex' value returned with the cursor_info which can be used to get the actual datetime from the original variable this of course is not really an elegant solution.
Hope anybody can shed some light on working with a datetime ruler. I'm using Matlab2017a by the way.
Thanks!
  4 个评论
Eric Delgado
Eric Delgado 2021-2-6
I am having the same issue... And I couldn't find a solution using num2ruler or ruler2num functions to convert a DateTimeRuler axes into a NumericRuler axes. Hey @Nikolaus Koopmann, is it possible to use this function to change the ruler of the axes?!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by