BUG: plot_surface ignores lightsource when cmap/facecolors are not specified · Issue #8877 · matplotlib/matplotlib · GitHub
Skip to content

BUG: plot_surface ignores lightsource when cmap/facecolors are not specified #8877

Description

@eric-wieser

Three different, undocumented, cases that I think should be the same:

  1. plot_surface(..., shade=True, lightsource=..., cmap=..., facecolors="garbage") - uses LightSource.shade, which does some messy and unnecessary trig in LightSource.hillshade, using the orientation of the lightsource.

  2. plot_surface(..., shade=True, lightsource=..., cmap=...) - uses _shade_colors, which does a more sensible vector-based approach, but hard-codes a [-1, -1, 0.5] normal vector, rather than respecting the lightsource direction.

  3. plot_surface(..., shade=True, lightsource=..., facecolors="garbage") - as above

Regarding (2), I think that there is a typo in axes3d.py, and this change should be made:

         # Shade the data
-        if shade and cmap is not None and fcolors is not None:
+        if shade and cmap is not None and fcolors is None:
             fcolors = self._shade_colors_lightsource(Z, cmap, lightsource)

It seems dumb to only calculate face colors if the user already asked for different ones.

Regarding (3) - I think it would be useful to unify the shading into a normal-vector based approach, which I might try in a later patch

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actiontopic: mplot3d

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions