Datetime bug in R2016b when saving figure that has a legend

4 views (last 30 days)
I am running Matlab R2016b and have a figure that is plotting a datenum class vector vs a vector of doubles (see sample script below). When running the code, if "legend show" is commented out, the code runs successfully and my figure is saved and able to be re-opened. If "legend show" is un-commented, I receive the error "Caught "std::exception" Exception message is: Access violation - no RTTI data!" and my figure is not saved. If I try to save the figure by clicking File >> Save and save as *.fig, I receive the error "Error while evaluating menu Callback". Saving as *.png or *.bmp is successful. I've run the same script in Matlab 2015a and it did not exhibit this bug (i.e. saving as a *.fig was successful).
Also, for what it's worth, R2016b auto-formats the x-axis into HH:MM:SS format, while R2015a formats as HH:MM (this is not problematic, just an observation).
Code:
clear all; close all; clc;
seconds_since_epoch = 1963156824:1:1963157000;
x = datetime(seconds_since_epoch,'ConvertFrom','epochtime','Epoch','1904-01-01');
y = 1:length(x);
figure;
plot(x,y)
legend show
savefig(gcf,'untitled.fig')
  1 Comment
Michael
Michael on 8 Feb 2017
I have exactly the same problem with Matlab R2016b wiht a figure, where a duration class vector vs a double class vector is plotted.

Sign in to comment.

Answers (3)

Peter Perkins
Peter Perkins on 6 Jan 2017
This seems to be a sporadic issue, and I've made a note to have it looked into. You should see a bug report posted sometime soon. Using 'compact' in your call to savefig should avoid the error:
savefig(f,'myfig_legend.fig','compact')
Hope this helps.
  2 Comments
Charles Boardman
Charles Boardman on 9 Feb 2017
I have the same issue using R2016b on Windows 7 64 bit machine. Plotting time series data. Trying to save the figure results in "Error while evaluating Menu Callback" or if you use the savefig command then "Access violation - no RTTI data!.
This only occurs when there is a legend in the figure.
The existing bug report does not provide enough detail to be able to reproduce the issue.

Sign in to comment.


Lionel
Lionel on 5 Jan 2017
I have the same issue, without the legend I am able to save the figure in .fig but not with it. I am running the following version of Matlab : R2016b(9.1.0.441655). Thanks for the help.
dt = (datetime+minutes(0:60))';
y = rand(size(dt));
f = figure;
plot(dt,y,'DisplayName','rand')
savefig(f,'myfig.fig') % working fine
legend('show')
savefig(f,'myfig_legend.fig') % error
Error : Caught "std::exception" Exception message is: Access violation - no RTTI data!

Peter Perkins
Peter Perkins on 2 Dec 2016
Kristin, I can't reproduce this in R2016b on either windows or mac. Is it possible you're using a pre-release version of R2016b?

Community Treasure Hunt

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

Start Hunting!