1010
1111from mathics .core .evaluation import Evaluation
1212from mathics .core .symbols import strip_context
13+ from mathics .core .systemsymbols import SymbolRGBColor , SymbolNone
1314from mathics .timing import Timer
1415
1516from .plot_compile import plot_compile
@@ -34,7 +35,20 @@ def eval_Plot3D(
3435 ys = np .linspace (ymin , ymax , ny )
3536 xs , ys = np .meshgrid (xs , ys )
3637
37- for function in plot_options .functions :
38+ # https://davidmathlogic.com/colorblind
39+ palette = [
40+ (255 , 176 , 0 ), # orange
41+ (100 , 143 , 255 ), # blue
42+ (220 , 38 , 127 ), # red
43+ (50 , 150 , 140 ), # green
44+ (120 , 94 , 240 ), # purple
45+ #(240, 228, 66), # yellow
46+ (254 , 97 , 0 ), # dark orange
47+ (0 , 114 , 178 ), # dark blue
48+ #(0, 0, 0), # black
49+ ]
50+
51+ for i , function in enumerate (plot_options .functions ):
3852 with Timer ("compile" ):
3953 function = plot_compile (evaluation , function , names )
4054
@@ -73,9 +87,15 @@ def eval_Plot3D(
7387 # ugh - indexes in Polygon are 1-based
7488 quads += 1
7589
90+ # choose a color
91+ rgb = palette [i % len (palette )]
92+ rgb = [c / 255.0 for c in rgb ]
93+ graphics .add_color (SymbolRGBColor , rgb )
94+
7695 # add a GraphicsComplex for this function
7796 graphics .add_complex (xyzs , lines = None , polys = quads )
7897
98+
7999 return graphics
80100
81101
0 commit comments