#NEWLINE# def test_mesh_mask_custom_colors( r = 1.0 , npts = ( 100 , 100 ) ) : #NEWLINE# #INDENT# 'Create a sphere with masking and using a custom colormap.\n\n    Note that masking works only when scalars are set.  The custom colormap\n    illustrates how one can completely customize the colors with numpy arrays.\n    In this case we use a simple 2 color colormap.\n    ' #NEWLINE# pi = numpy . pi #NEWLINE# cos = numpy . cos #NEWLINE# sin = numpy . sin #NEWLINE# np_phi = ( npts [ 0 ] * 1j ) #NEWLINE# np_theta = ( npts [ 1 ] * 1j ) #NEWLINE# ( phi , theta ) = numpy . mgrid [ 0 : pi : np_phi , 0 : ( 2 * pi ) : np_theta ] #NEWLINE# x = ( ( r * sin ( phi ) ) * cos ( theta ) ) #NEWLINE# y = ( ( np_phi * sin ( phi ) ) * sin ( theta ) ) #NEWLINE# z = ( r * cos ( phi ) ) #NEWLINE# mask = numpy . zeros_like ( x ) . astype ( bool ) #NEWLINE# mask [ : : 5 ] = True #NEWLINE# mask [ : , : : 5 ] = True #NEWLINE# m = mesh ( x , y , z , scalars = z , mask = mask ) #NEWLINE# colors = numpy . zeros ( ( 2 , 4 ) , dtype = 'uint8' ) #NEWLINE# colors [ ( 0 , 2 ) ] = 255 #NEWLINE# colors [ ( 1 , 1 ) ] = 255 #NEWLINE# colors [ : , 3 ] = 255 #NEWLINE# m . module_manager . scalar_lut_manager . lut . table = colors #NEWLINE# return m