Skip to content

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

@eric-wieser

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

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy