Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Saving Figure in saveplotlyfig in MATLAB R2024b #522

Open
RoyiAvital opened this issue Feb 26, 2025 · 5 comments
Open

Error Saving Figure in saveplotlyfig in MATLAB R2024b #522

RoyiAvital opened this issue Feb 26, 2025 · 5 comments

Comments

@RoyiAvital
Copy link

In saveplotlyfig the following will fail:

elseif ishandle(figure_or_data)
        if strcmp(handle(figure_or_data).classhandle.name,'figure')
            p = plotlyfig(figure_or_data, 'strip', false);

As handle(figure_or_data).classhandle will generate nrecognized method, property, or field 'classhandle' for class 'matlab.ui.Figure'..

@RoyiAvital
Copy link
Author

Currently I edited:

function p = saveplotlyfig(figure_or_data, filename, varargin)

    %--PARSE FIGURE_OR_DATA--%
    if iscell(figure_or_data)
        p = plotlyfig('Visible','off');
        p.data = figure_or_data;
        p.layout = struct(); 
        p.PlotOptions.Strip = false; 
    elseif isstruct(figure_or_data);
        p = plotlyfig('Visible','off');
        p.data = figure_or_data.data;
        p.layout = figure_or_data.layout;
        p.PlotOptions.Strip = false; 
    elseif isa(figure_or_data, 'plotlyfig')
        p = figure_or_data;
        p.PlotOptions.Strip = false;
    elseif ishandle(figure_or_data)
        % if strcmp(handle(figure_or_data).classhandle.name,'figure')
        %----Royi----%
        if strcmp(get(figure_or_data, 'type'), 'figure')
        %----Royi----%
            p = plotlyfig(figure_or_data, 'strip', false);
        end
    else
        errkey = 'plotlySaveImage:invalidInputs';
        error(errkey,plotlymsg(errkey));
    end

    %--MAKE CALL TO SAVEAS METHOD--%
    p.saveas(filename, varargin{:});
end

@RoyiAvital
Copy link
Author

OK, Even after the fix I can't save the figure.

@robertoffmoura
Copy link
Collaborator

Hi, could you please share some steps to reproduce this issue? E.g. a minimal reproducible example or a detailed description of the actions leading to the issue. This will help investigate the problem more effectively. Thanks!

@RoyiAvital
Copy link
Author

Nothing special. Just using the latest version of PlotLy with MATLAB R2024b.

@robertoffmoura
Copy link
Collaborator

Do you have a script to generate the plot you're trying to save with saveplotlyfig?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants