@@ -2120,5 +2120,394 @@ function testAxisLabelSizeFont(tc)
21202120 family = " Droid Sans, sans-serif" ...
21212121 ));
21222122 end
2123+
2124+ function testMeshPlotData(tc )
2125+ fig = figure(" Visible" ," off" );
2126+ [X ,Y ] = meshgrid(linspace(-2 ,2 ,15 ));
2127+ Z = X .* exp(-X .^ 2 - Y .^ 2 );
2128+ mesh(X ,Y ,Z );
2129+
2130+ p = plotlyfig(fig ," visible" ," off" );
2131+
2132+ tc .verifyNumElements(p .data , 1 );
2133+ tc .verifyEqual(rmfield(p.data{1 }, [" colorscale" " surfacecolor" ]), struct( ...
2134+ xaxis = " x1" , ...
2135+ yaxis = " y1" , ...
2136+ type = " surface" , ...
2137+ x = X , ...
2138+ y = Y , ...
2139+ z = Z , ...
2140+ contours = struct( ...
2141+ x = struct( ...
2142+ " end" , 2 , ...
2143+ start = - 2 , ...
2144+ size = 0.285714285714286 , ...
2145+ show = true , ...
2146+ color = " black" ...
2147+ ), ...
2148+ y = struct( ...
2149+ " end" , 2 , ...
2150+ start = - 2 , ...
2151+ size = 0.285714285714286 , ...
2152+ show = true , ...
2153+ color = " black" ...
2154+ ) ...
2155+ ), ...
2156+ name = ' ' , ...
2157+ showscale = false , ...
2158+ visible = true , ...
2159+ showlegend = true ...
2160+ ), AbsTol= 1e- 15 );
2161+ end
2162+
2163+ function testRibbonPlotData(tc )
2164+ fig = figure(" Visible" ," off" );
2165+ n = 50 ;
2166+ x = linspace(0 ,4 * pi ,n );
2167+ y = [sin(x ); sin(x )+0.5 ; sin(x )+1 ]' ;
2168+ ribbon(x ,y );
2169+
2170+ p = plotlyfig(fig ," visible" ," off" );
2171+
2172+ tc .verifyNumElements(p .data , 3 );
2173+ tc .verifyEqual(rmfield(p.data{1 }, [" colorscale" " surfacecolor" ]), struct( ...
2174+ xaxis = " x1" , ...
2175+ yaxis = " y1" , ...
2176+ type = " surface" , ...
2177+ x = repmat([0.625 1.375 ], n , 1 ), ...
2178+ y = repmat(x(: ), 1 , 2 ), ...
2179+ z = repmat(y(: ,1 ), 1 , 2 ), ...
2180+ contours = struct( ...
2181+ x = struct( ...
2182+ " end" , 1.375 , ...
2183+ start = 0.625 , ...
2184+ size = 0.75 , ...
2185+ show = true , ...
2186+ color = " black" ...
2187+ ), ...
2188+ y = struct( ...
2189+ " end" , max(x ), ...
2190+ start = min(x ), ...
2191+ size = rangeLength(x(: )) / (size(x , 2 )-1 ), ...
2192+ show = true , ...
2193+ color = " black" ...
2194+ ) ...
2195+ ), ...
2196+ name = ' ' , ...
2197+ showscale = false , ...
2198+ visible = true , ...
2199+ showlegend = true ...
2200+ ), AbsTol= 1e- 15 );
2201+ end
2202+
2203+ function testPatchPlotData(tc )
2204+ fig = figure(" Visible" ," off" );
2205+ x = [0 1 1 0 ];
2206+ y = [0 0 1 1 ];
2207+ patch(x , y , " red" );
2208+
2209+ p = plotlyfig(fig ," visible" ," off" );
2210+
2211+ tc .verifyNumElements(p .data , 1 );
2212+ tc .verifyEqual(p.data{1 }, struct( ...
2213+ xaxis = " x1" , ...
2214+ yaxis = " y1" , ...
2215+ type = ' scatter' , ...
2216+ x = [x x(1 )], ...
2217+ y = [y y(1 )], ...
2218+ name = ' ' , ...
2219+ visible = true , ...
2220+ fill = ' tozeroy' , ...
2221+ mode = ' lines' , ...
2222+ line = struct( ...
2223+ color = " rgb(0,0,0)" , ...
2224+ width = 0.5 , ...
2225+ dash = " solid" ...
2226+ ), ...
2227+ marker = struct( ...
2228+ sizeref = 1 , ...
2229+ sizemode = " diameter" , ...
2230+ size = 6 , ...
2231+ line = struct( ...
2232+ width = 0.5 ...
2233+ ), ...
2234+ color = " rgb(0,0,0)" ...
2235+ ), ...
2236+ fillcolor = " rgba(255,0,0,1.000000)" , ...
2237+ showlegend = false ...
2238+ ));
2239+ end
2240+
2241+ function testFillPlotData(tc )
2242+ fig = figure(" Visible" ," off" );
2243+ x1 = [1 2 3 4 5 ];
2244+ y1 = [1 2 1 2 1 ];
2245+ x2 = [1 2 3 4 5 ];
2246+ y2 = [2 3 2 3 2 ];
2247+ fill(x1 , y1 , ' blue' , x2 , y2 , ' green' );
2248+
2249+ p = plotlyfig(fig ," visible" ," off" );
2250+
2251+ tc .verifyNumElements(p .data , 2 );
2252+ tc .verifyEqual(p.data{1 }, struct( ...
2253+ xaxis = " x1" , ...
2254+ yaxis = " y1" , ...
2255+ type = ' scatter' , ...
2256+ x = [x1 x1(1 )], ...
2257+ y = [y1 y1(1 )], ...
2258+ name = ' ' , ...
2259+ visible = true , ...
2260+ fill = ' tozeroy' , ...
2261+ mode = ' lines' , ...
2262+ line = struct( ...
2263+ color = " rgb(0,0,0)" , ...
2264+ width = 0.5 , ...
2265+ dash = " solid" ...
2266+ ), ...
2267+ marker = struct( ...
2268+ sizeref = 1 , ...
2269+ sizemode = " diameter" , ...
2270+ size = 6 , ...
2271+ line = struct( ...
2272+ width = 0.5 ...
2273+ ), ...
2274+ color = " rgb(0,0,0)" ...
2275+ ), ...
2276+ fillcolor = " rgba(0,0,255,1.000000)" , ...
2277+ showlegend = false ...
2278+ ));
2279+ tc .verifyEqual(p.data{2 }, struct( ...
2280+ xaxis = " x1" , ...
2281+ yaxis = " y1" , ...
2282+ type = ' scatter' , ...
2283+ x = [x2 x2(1 )], ...
2284+ y = [y2 y2(1 )], ...
2285+ name = ' ' , ...
2286+ visible = true , ...
2287+ fill = ' tozeroy' , ...
2288+ mode = ' lines' , ...
2289+ line = struct( ...
2290+ color = " rgb(0,0,0)" , ...
2291+ width = 0.5 , ...
2292+ dash = " solid" ...
2293+ ), ...
2294+ marker = struct( ...
2295+ sizeref = 1 , ...
2296+ sizemode = " diameter" , ...
2297+ size = 6 , ...
2298+ line = struct( ...
2299+ width = 0.5 ...
2300+ ), ...
2301+ color = " rgb(0,0,0)" ...
2302+ ), ...
2303+ fillcolor = " rgba(0,255,0,1.000000)" , ...
2304+ showlegend = false ...
2305+ ));
2306+ end
2307+
2308+ function testCompassPlotData(tc )
2309+ fig = figure(" Visible" ," off" );
2310+ u = [1 2 - 1 - 2 ];
2311+ v = [1 - 1 1 - 1 ];
2312+ compass(u , v );
2313+
2314+ p = plotlyfig(fig ," visible" ," off" );
2315+
2316+ tc .verifyNumElements(p .data , 4 );
2317+ tc .verifyEqual(p.data{1 }, struct( ...
2318+ type = " scatter" , ...
2319+ xaxis = " x1" , ...
2320+ yaxis = " y1" , ...
2321+ visible = true , ...
2322+ name = ' ' , ...
2323+ mode = ' lines' , ...
2324+ x = [0 1 0.72 1 0.88 ], ...
2325+ y = [0 1 0.88 1 0.72 ], ...
2326+ line = struct( ...
2327+ color = " rgb(0,114,189)" , ...
2328+ width = 0.5 , ...
2329+ dash = " solid" ...
2330+ ), ...
2331+ marker = struct( ...
2332+ size = 3.6 , ...
2333+ line = struct( ...
2334+ width = 0.5 ...
2335+ ), ...
2336+ color = " rgb(0,114,189)" ...
2337+ ), ...
2338+ showlegend = false ...
2339+ ), AbsTol= 1e- 15 );
2340+ end
2341+
2342+ function testFeatherPlotData(tc )
2343+ fig = figure(" Visible" ," off" );
2344+ theta = (0 : 15 : 360 )*pi / 180 ;
2345+ r = 2 * cos(2 * theta ).^2 + 1 ;
2346+ u = r .* cos(theta );
2347+ v = r .* sin(theta );
2348+ feather(u , v );
2349+
2350+ p = plotlyfig(fig ," visible" ," off" );
2351+
2352+ tc .verifyNumElements(p .data , numel(theta )+1 );
2353+ tc .verifyEqual(p.data{1 }, struct( ...
2354+ type = " scatter" , ...
2355+ xaxis = " x1" , ...
2356+ yaxis = " y1" , ...
2357+ visible = true , ...
2358+ name = ' ' , ...
2359+ mode = ' lines' , ...
2360+ x = [1 4 NaN 3.4 4 3.4 ], ...
2361+ y = [0 0 NaN 0.24 0 - 0.24 ], ...
2362+ line = struct( ...
2363+ color = " rgb(0,114,189)" , ...
2364+ width = 0.5 , ...
2365+ dash = " solid" ...
2366+ ), ...
2367+ marker = struct( ...
2368+ size = 3.6 , ...
2369+ line = struct( ...
2370+ width = 0.5 ...
2371+ ), ...
2372+ color = " rgb(0,114,189)" ...
2373+ ), ...
2374+ showlegend = false ...
2375+ ), AbsTol= 1e- 15 );
2376+ end
2377+
2378+ function testSemilogyPlotData(tc )
2379+ fig = figure(" Visible" ," off" );
2380+ x = 0 : 0.1 : 10 ;
2381+ y = x ;
2382+ semilogy(x , y );
2383+
2384+ p = plotlyfig(fig ," visible" ," off" );
2385+
2386+ tc .verifyNumElements(p .data , 1 );
2387+ tc .verifyEqual(p.data{1 }, struct( ...
2388+ type = " scatter" , ...
2389+ xaxis = " x1" , ...
2390+ yaxis = " y1" , ...
2391+ visible = true , ...
2392+ name = ' ' , ...
2393+ mode = ' lines' , ...
2394+ x = x , ...
2395+ y = y , ...
2396+ line = struct( ...
2397+ color = " rgb(0,114,189)" , ...
2398+ width = 0.5 , ...
2399+ dash = " solid" ...
2400+ ), ...
2401+ marker = struct( ...
2402+ size = 3.6 , ...
2403+ line = struct( ...
2404+ width = 0.5 ...
2405+ ), ...
2406+ color = " rgb(0,114,189)" ...
2407+ ), ...
2408+ showlegend = false ...
2409+ ), AbsTol= 1e- 15 );
2410+ end
2411+
2412+ function testSemilogxPlotData(tc )
2413+ fig = figure(" Visible" ," off" );
2414+ x = 0 : 0.1 : 10 ;
2415+ y = x ;
2416+ semilogx(x , y );
2417+
2418+ p = plotlyfig(fig ," visible" ," off" );
2419+
2420+ tc .verifyNumElements(p .data , 1 );
2421+ tc .verifyEqual(p.data{1 }, struct( ...
2422+ type = " scatter" , ...
2423+ xaxis = " x1" , ...
2424+ yaxis = " y1" , ...
2425+ visible = true , ...
2426+ name = ' ' , ...
2427+ mode = ' lines' , ...
2428+ x = x , ...
2429+ y = y , ...
2430+ line = struct( ...
2431+ color = " rgb(0,114,189)" , ...
2432+ width = 0.5 , ...
2433+ dash = " solid" ...
2434+ ), ...
2435+ marker = struct( ...
2436+ size = 3.6 , ...
2437+ line = struct( ...
2438+ width = 0.5 ...
2439+ ), ...
2440+ color = " rgb(0,114,189)" ...
2441+ ), ...
2442+ showlegend = false ...
2443+ ), AbsTol= 1e- 15 );
2444+ end
2445+
2446+ function testGroupedBarPlotData(tc )
2447+ fig = figure(" Visible" ," off" );
2448+ y = [2 5 3 ; 6 1 4 ; 3 7 2 ];
2449+ bar(y );
2450+
2451+ p = plotlyfig(fig ," visible" ," off" );
2452+
2453+ tc .verifyNumElements(p .data , 3 );
2454+ tc .verifyEqual(p.data{1 }, struct( ...
2455+ xaxis = " x1" , ...
2456+ yaxis = " y1" , ...
2457+ type = " bar" , ...
2458+ name = ' ' , ...
2459+ visible = true , ...
2460+ orientation = " v" , ...
2461+ x = [1 2 3 ], ...
2462+ y = y(: ,1 )' , ...
2463+ marker = struct( ...
2464+ color = " rgba(0,114,189,1.000000)" , ...
2465+ line = struct( ...
2466+ color = " rgba(0,0,0,1.000000)" , ...
2467+ width = 0.5 , ...
2468+ dash = " solid" ...
2469+ ) ...
2470+ ), ...
2471+ showlegend = true ...
2472+ ));
2473+ tc .verifyEqual(p.data{2 }, struct( ...
2474+ xaxis = " x1" , ...
2475+ yaxis = " y1" , ...
2476+ type = " bar" , ...
2477+ name = ' ' , ...
2478+ visible = true , ...
2479+ orientation = " v" , ...
2480+ x = [1 2 3 ], ...
2481+ y = y(: ,2 )' , ...
2482+ marker = struct( ...
2483+ color = " rgba(217,83,25,1.000000)" , ...
2484+ line = struct( ...
2485+ color = " rgba(0,0,0,1.000000)" , ...
2486+ width = 0.5 , ...
2487+ dash = " solid" ...
2488+ ) ...
2489+ ), ...
2490+ showlegend = true ...
2491+ ));
2492+ tc .verifyEqual(p.data{3 }, struct( ...
2493+ xaxis = " x1" , ...
2494+ yaxis = " y1" , ...
2495+ type = " bar" , ...
2496+ name = ' ' , ...
2497+ visible = true , ...
2498+ orientation = " v" , ...
2499+ x = [1 2 3 ], ...
2500+ y = y(: ,3 )' , ...
2501+ marker = struct( ...
2502+ color = " rgba(237,177,32,1.000000)" , ...
2503+ line = struct( ...
2504+ color = " rgba(0,0,0,1.000000)" , ...
2505+ width = 0.5 , ...
2506+ dash = " solid" ...
2507+ ) ...
2508+ ), ...
2509+ showlegend = true ...
2510+ ));
2511+ end
21232512 end
21242513end
0 commit comments