getpts - can't select multiple points when plot contains datetime axis
이전 댓글 표시
Time = [datetime('now'):seconds(1):datetime('now')+minutes(1)];
Value = randn(61,1);
plot(Time, Value);
[TimePoints, ~] = getpts;
When I select one point (left-click) and press return, everything is fine. But when I try to select multiple points I get this error message:
Error using datetime/horzcat (line 1292)
All inputs must be datetimes or date/time character vectors or date/time
strings.
Error in getpts>NextButtonDown (line 250)
set([GETPTS_H1 GETPTS_H2], 'XData', [x newx], ...
Error in getpts (line 36)
feval(varargin{:});
Error using getpts (line 108)
Error while evaluating Figure WindowButtonDownFcn.
The getpts documentation says that the output argument is a double. I presume that is the issue. But it will return one datetime value. So I'm hoping there's a way to get it to return more. Is that possible? Or do I have to convert the datetime values to datenum values, make the plot, use getpts and then convert them back again? Thanks.
댓글 수: 3
dpb
2018년 8월 11일
>> which -all getpts
'getpts' not found.
>>
Isn't found at R2018a online search, either...
Adam Reynolds
2018년 8월 11일
Hmmm...I don't have the TB and the TMW search engine didn't locate it and it wasn't at FEX so I didn't know.
This time it did locate...not sure what's up w/ that.
As you say, the doc clearly indicates it expects only a double as its return; it hasn't been updated to handle the overloaded plot functions.
You've got the option you outlined which would be somewhat painful or, since it's an m-file you could look into its handling of returned values and see how complex it might be to add the facility to handle datetime return values; since I don't have TB, can't see the code here to tell.
I don't know how feasible it would be to install a callback routine to trap the returned coordinate to do the conversion; you probably will have to make changes in the function itself but might see if they left a hook available.
Definitely worth at least an enhancement request if not bug report...
ADDENDUM TMW may think since it's in Image Processing TB that images don't have datetime axes...
ginput does return an array of coordinates but I've not yet exactly figured out the x-axes scaling when in datetime coordinates...
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!