@@ -420,6 +420,33 @@ def test_surface3d_shaded():
420
420
ax .set_zlim (- 1.01 , 1.01 )
421
421
422
422
423
+ @mpl3d_image_comparison (['surface3d_masked.png' ])
424
+ def test_surface3d_masked ():
425
+ fig = plt .figure ()
426
+ ax = fig .add_subplot (projection = '3d' )
427
+ x = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ]
428
+ y = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
429
+
430
+ x , y = np .meshgrid (x , y )
431
+ matrix = np .array (
432
+ [
433
+ [- 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ],
434
+ [- 1 , 1 , 2 , 3 , 4 , 4 , 4 , 3 , 2 , 1 , 1 ],
435
+ [- 1 , - 1. , 4 , 5 , 6 , 8 , 6 , 5 , 4 , 3 , - 1. ],
436
+ [- 1 , - 1. , 7 , 8 , 11 , 12 , 11 , 8 , 7 , - 1. , - 1. ],
437
+ [- 1 , - 1. , 8 , 9 , 10 , 16 , 10 , 9 , 10 , 7 , - 1. ],
438
+ [- 1 , - 1. , - 1. , 12 , 16 , 20 , 16 , 12 , 11 , - 1. , - 1. ],
439
+ [- 1 , - 1. , - 1. , - 1. , 22 , 24 , 22 , 20 , 18 , - 1. , - 1. ],
440
+ [- 1 , - 1. , - 1. , - 1. , - 1. , 28 , 26 , 25 , - 1. , - 1. , - 1. ],
441
+ ]
442
+ )
443
+ z = np .ma .masked_less (matrix , 0 )
444
+ norm = mcolors .Normalize (vmax = z .max (), vmin = z .min ())
445
+ colors = plt .get_cmap ("plasma" )(norm (z ))
446
+ ax .plot_surface (x , y , z , facecolors = colors )
447
+ ax .view_init (30 , - 80 )
448
+
449
+
423
450
@mpl3d_image_comparison (['text3d.png' ], remove_text = False )
424
451
def test_text3d ():
425
452
fig = plt .figure ()
0 commit comments