@@ -3534,43 +3534,62 @@ function testHistPlotData(tc)
35343534 ), ...
35353535 " color" , PlotlyTestCase .AnyColorString() ...
35363536 ), ...
3537- " name" , ' ' , ...
3537+ " name" , ' x ' , ...
35383538 " visible" , true , ...
3539- " showlegend" , false ...
3539+ " showlegend" , true ...
35403540 );
3541+ if is_octave()
3542+ % MATLAB's hist() names the trace after the data
3543+ % variable and shows it in the legend
3544+ expected.name = ' ' ;
3545+ expected.showlegend = false ;
3546+ end
35413547 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
35423548 try close(); catch ; end
35433549 end
35443550
35453551 function testBar3PlotData(tc )
35463552 % bar3 emits one mesh3d face trace plus per-bar edge
3547- % traces on scene1.
3553+ % traces on scene1. MATLAB's bar3 draws a surface object
3554+ % that converts to a plain surface trace instead.
35483555 fig = figure(" Visible" ," off" );
35493556 bar3(peaks(5 )/10 );
35503557
35513558 p = plotlyfig(fig ," visible" ," off" );
35523559
35533560 expected = struct( ...
3554- " xaxis" , " x1" , ...
3555- " yaxis" , " y1" , ...
3556- " type" , " mesh3d" , ...
3561+ " type" , " surface" , ...
3562+ " scene" , " scene1" , ...
3563+ " visible" , true , ...
3564+ " name" , ' ' , ...
35573565 " x" , PlotlyTestCase .Any(), ...
35583566 " y" , PlotlyTestCase .Any(), ...
35593567 " z" , PlotlyTestCase .Any(), ...
3560- " i" , PlotlyTestCase .Any(), ...
3561- " j" , PlotlyTestCase .Any(), ...
3562- " k" , PlotlyTestCase .Any(), ...
3563- " color" , PlotlyTestCase .AnyColorString(), ...
3564- " intensity" , PlotlyTestCase .Any(), ...
3565- " cmin" , PlotlyTestCase .Any(), ...
3568+ " surfacecolor" , PlotlyTestCase .Any(), ...
35663569 " cmax" , PlotlyTestCase .Any(), ...
3570+ " cmin" , PlotlyTestCase .Any(), ...
35673571 " colorscale" , PlotlyTestCase .Any(), ...
3568- " showscale " , false , ...
3569- " scene " , " scene1 " , ...
3570- " name " , ' ' , ...
3571- " visible " , true , ...
3572+ " contours " , PlotlyTestCase .Any() , ...
3573+ " lighting " , PlotlyTestCase .Any() , ...
3574+ " opacity " , PlotlyTestCase .Any() , ...
3575+ " showscale " , PlotlyTestCase .Any() , ...
35723576 " showlegend" , false ...
35733577 );
3578+ if is_octave()
3579+ % Octave's bar3 patches convert to a mesh3d face
3580+ % trace with per-bar edge traces
3581+ expected = rmfield(expected , ...
3582+ {' surfacecolor' , ' contours' , ' lighting' , ' opacity' });
3583+ expected.xaxis = " x1" ;
3584+ expected.yaxis = " y1" ;
3585+ expected.type = " mesh3d" ;
3586+ expected.i = PlotlyTestCase .Any();
3587+ expected.j = PlotlyTestCase .Any();
3588+ expected.k = PlotlyTestCase .Any();
3589+ expected.color = PlotlyTestCase .AnyColorString();
3590+ expected.intensity = PlotlyTestCase .Any();
3591+ expected.showscale = false ;
3592+ end
35743593 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
35753594 if is_octave()
35763595 tc .verifyNumElements(p .data, 151 );
@@ -3583,33 +3602,46 @@ function testBar3PlotData(tc)
35833602
35843603 function testBar3hPlotData(tc )
35853604 % bar3h emits one mesh3d face trace plus per-bar edge
3586- % traces on scene1.
3605+ % traces on scene1. MATLAB's bar3h draws a surface object
3606+ % that converts to a plain surface trace instead.
35873607 fig = figure(" Visible" ," off" );
35883608 bar3h(peaks(5 )/10 );
35893609
35903610 p = plotlyfig(fig ," visible" ," off" );
35913611
35923612 expected = struct( ...
3593- " xaxis" , " x1" , ...
3594- " yaxis" , " y1" , ...
3595- " type" , " mesh3d" , ...
3613+ " type" , " surface" , ...
3614+ " scene" , " scene1" , ...
3615+ " visible" , true , ...
3616+ " name" , ' ' , ...
35963617 " x" , PlotlyTestCase .Any(), ...
35973618 " y" , PlotlyTestCase .Any(), ...
35983619 " z" , PlotlyTestCase .Any(), ...
3599- " i" , PlotlyTestCase .Any(), ...
3600- " j" , PlotlyTestCase .Any(), ...
3601- " k" , PlotlyTestCase .Any(), ...
3602- " color" , PlotlyTestCase .AnyColorString(), ...
3603- " intensity" , PlotlyTestCase .Any(), ...
3604- " cmin" , PlotlyTestCase .Any(), ...
3620+ " surfacecolor" , PlotlyTestCase .Any(), ...
36053621 " cmax" , PlotlyTestCase .Any(), ...
3622+ " cmin" , PlotlyTestCase .Any(), ...
36063623 " colorscale" , PlotlyTestCase .Any(), ...
3607- " showscale " , false , ...
3608- " scene " , " scene1 " , ...
3609- " name " , ' ' , ...
3610- " visible " , true , ...
3624+ " contours " , PlotlyTestCase .Any() , ...
3625+ " lighting " , PlotlyTestCase .Any() , ...
3626+ " opacity " , PlotlyTestCase .Any() , ...
3627+ " showscale " , PlotlyTestCase .Any() , ...
36113628 " showlegend" , false ...
36123629 );
3630+ if is_octave()
3631+ % Octave's bar3h patches convert to a mesh3d face
3632+ % trace with per-bar edge traces
3633+ expected = rmfield(expected , ...
3634+ {' surfacecolor' , ' contours' , ' lighting' , ' opacity' });
3635+ expected.xaxis = " x1" ;
3636+ expected.yaxis = " y1" ;
3637+ expected.type = " mesh3d" ;
3638+ expected.i = PlotlyTestCase .Any();
3639+ expected.j = PlotlyTestCase .Any();
3640+ expected.k = PlotlyTestCase .Any();
3641+ expected.color = PlotlyTestCase .AnyColorString();
3642+ expected.intensity = PlotlyTestCase .Any();
3643+ expected.showscale = false ;
3644+ end
36133645 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
36143646 if is_octave()
36153647 tc .verifyNumElements(p .data, 151 );
@@ -3632,34 +3664,41 @@ function testStem3PlotData(tc)
36323664 p = plotlyfig(fig ," visible" ," off" );
36333665
36343666 tc .verifyNumElements(p .data, 1 );
3635- expectedX = reshape([x ; x ; nan(1 ,length(x ))], 1 , []);
3636- expectedY = reshape([y ; y ; nan(1 ,length(y ))], 1 , []);
3637- expectedZ = reshape([zeros(1 ,length(z )); z ; nan(1 ,length(z ))], 1 , []);
36383667 expected = struct( ...
36393668 " type" , " scatter3d" , ...
36403669 " scene" , " scene1" , ...
36413670 " visible" , true , ...
36423671 " name" , ' ' , ...
36433672 " mode" , ' lines+markers' , ...
3644- " x" , expectedX , ...
3645- " y" , expectedY , ...
3646- " z" , expectedZ , ...
3673+ " x" , reshape([ x ; x ; nan( 1 ,length( x ))], [], 1 ) , ...
3674+ " y" , reshape([ y ; y ; nan( 1 ,length( y ))], [], 1 ) , ...
3675+ " z" , reshape([zeros( 1 ,length( z )); z ; nan( 1 ,length( z ))], [], 1 ) , ...
36473676 " line" , struct( ...
36483677 " color" , PlotlyTestCase .AnyColorString(), ...
3649- " width" , 0.5 , ...
3678+ " width" , 1 , ...
36503679 " dash" , " solid" ...
36513680 ), ...
36523681 " marker" , struct( ...
3653- " size" , 3.6 , ...
3682+ " size" , 2.16 , ...
36543683 " symbol" , " circle" , ...
36553684 " line" , struct( ...
3656- " width" , 0.5 , ...
3685+ " width" , 1 , ...
36573686 " color" , PlotlyTestCase .Any() ...
36583687 ), ...
36593688 " color" , PlotlyTestCase .Any() ...
36603689 ), ...
36613690 " showlegend" , false ...
36623691 );
3692+ if is_octave()
3693+ % MATLAB's updateStem doubles the widths and emits
3694+ % column vectors; Octave's updateStemseries does not
3695+ expected.x = reshape([x ; x ; nan(1 ,length(x ))], 1 , []);
3696+ expected.y = reshape([y ; y ; nan(1 ,length(y ))], 1 , []);
3697+ expected.z = reshape([zeros(1 ,length(z )); z ; nan(1 ,length(z ))], 1 , []);
3698+ expected.line.width = 0.5 ;
3699+ expected.marker.size = 3.6 ;
3700+ expected.marker.line.width = 0.5 ;
3701+ end
36633702 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
36643703 try close(); catch ; end
36653704 end
@@ -3740,6 +3779,10 @@ function testContourfPlotData(tc)
37403779 ), ...
37413780 " showlegend" , false ...
37423781 );
3782+ if ~is_octave()
3783+ % MATLAB's contour handler adds reversescale
3784+ expected.reversescale = false ;
3785+ end
37433786 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
37443787 if is_octave()
37453788 tc .verifyEqual(size(p.data{1 }.z), [30 30 ]);
@@ -3774,6 +3817,12 @@ function testImagePlotData(tc)
37743817 " colorscale" , PlotlyTestCase .Any(), ...
37753818 " showlegend" , false ...
37763819 );
3820+ if ~is_octave()
3821+ % MATLAB's image CLim auto-ranges over the data
3822+ % instead of starting at 0
3823+ expected.zmin = get(gca , ' CLim' );
3824+ expected.zmin = expected .zmin(1 );
3825+ end
37773826 tc .verifyEqualStructs(p.data{1 }, expected , ' AbsTol' , 1e- 15 );
37783827 if is_octave()
37793828 % image data is stored with y reversed (top row first)
0 commit comments