plotly_matlab icon indicating copy to clipboard operation
plotly_matlab copied to clipboard

TreatAs pie3 broken (at least in R2024b)

Open Rolf-MP opened this issue 6 months ago • 0 comments

    pie3([1, 2, 3], [1, 0, 0])
   p = plotlyfig(myfigure, "offline", false, 'TreatAs', 'pie3')

Throws error

Dynamic field or property name must be a string scalar or character vector.

Error in setfield (line 14)
    s.(deblank(strField)) = varargin{end};    
    ^^^^^^^^^^^^^^^^^^^^^
Error in updatePie3 (line 38)
    obj.layout = setfield(obj.layout,['scene' ...
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in updateData (line 6)
        updatePie3(obj, dataIndex);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in plotlyfig/update (line 625)
                updateData(obj,n);
                ^^^^^^^^^^^^^^^^^
Error in plotlyfig (line 148)
                obj.update;
                ^^^^^^^^^^

This is caused by concatenation of a 'char array' and a "string" resulting in a 1x2 string array instead of a single string of a char array.

In plotly_matlab\plotly\plotlyfig_aux\handlegraphics\updatePie3.m

    %-update scene-%
    obj.layout = setfield(obj.layout,['scene' ...
            obj.PlotOptions.scene_anchor(end)], obj.PlotOptions.scene);
    obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor;
    obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor;

It seems it should read something like the below which concatenates two "string"s and also allows for multi digit scenes:

    %-update scene-%
    obj.layout = setfield(obj.layout, "scene" + ...
        regexp(obj.PlotOptions.scene_anchor, "\d+$", "match"), ...
        obj.PlotOptions.scene);
    obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor;
    obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor;

Rolf-MP avatar Jul 24 '25 15:07 Rolf-MP