Skip to content

Commit 28e1fc5

Browse files
committed
Little simpler. slightly faster
1 parent 833d790 commit 28e1fc5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mathics/eval/drawing/plot3d_vectorized.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,11 @@ def emit(graphics, i, xyzs, quads):
276276
# background is solid colors between contour lines
277277
if background:
278278
with Timer("contour background"):
279-
# add extra levels below zmin and above zmax to define end ranges
280-
levels = (
281-
[zmin - (levels[0] - zmin)]
282-
+ list(levels)
283-
+ [zmax + (zmax - levels[-1])]
284-
)
279+
# use masks and fancy indexing to assign (lo+hi)/2 to all zs between lo and hi
280+
zs[zs <= levels[0]] = zmin
285281
for lo, hi in zip(levels[:-1], levels[1:]):
286-
# use masks and fancy indexing to assign (lo+hi)/2 to all zs between lo and hi
287282
zs[(lo < zs) & (zs <= hi)] = (lo + hi) / 2
283+
zs[levels[-1] < zs] = zmax
288284
colors = density_colors(zs) # same colors as density plot
289285
graphics.add_complex(
290286
xyzs[:, 0:2], lines=None, polys=quads, colors=colors

0 commit comments

Comments
 (0)