Using datetime in surf plot
5 views (last 30 days)
Show older comments
stuckinthemuck
on 30 Jan 2015
Commented: Star Strider
on 2 Feb 2015
I have a bunch of subplots that are linked with linkaxes and I currently use the FEX function dynamicDateTicks to update the tick labels when I zoom. BUT. The new datetime format looks better (less crowded) on the graphs. Only I can't get it (datetime) to work with a surf plot.
Here's a minimal working example:
X = 25:25:100;
T = datenum(2015,01,01,1:4,0,0);
Z = [ 1 2 3 4;
5 6 7 8;
9 10 11 12;
13 14 15 16];
[Xmesh,Tmesh] = meshgrid(X,T);
% Tmesh = datetime(Tmesh,'ConvertFrom','datenum');
figure;
surf(Tmesh,Xmesh,Z);
If you uncomment the one line, this gives me the error:
Error using surf (line 57)
X, Y, Z, and C cannot be complex.
Anyone else have this problem? It seems like a bug, since it works fine with any other plot. For example:
plot(datetime(2014,01,1:2),1:2)
Any help would be appreciated. And just to be clear, I currently can get it all to work with dynamicDateTicks (datetick), I'm just hoping for a cleaner plot.
0 Comments
Accepted Answer
Star Strider
on 30 Jan 2015
I can’t find it in the documentation just now, but datetime doesn’t work with ‘surface’ plots. It works with 2D plots only.
I believe datetick will still work on ‘surface’ plots.
2 Comments
Star Strider
on 2 Feb 2015
My pleasure.
Unfortunate indeed. Maybe in the next version or two it will work with surface plots.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!