Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix and document lightsource argument in mplot3d #9990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 16, 2018

Conversation

eric-wieser
Copy link
Contributor

PR Summary

Fixes the problems in #8877, where the lightsource argument is broken in silly ways.

This has been sitting in my working tree a while now, but is freshly rebased.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@eric-wieser eric-wieser changed the title Lightsource shading Fix and document lightsource argument in mplot3d Dec 13, 2017
@eric-wieser
Copy link
Contributor Author

This will conflict with #9991, so lets deal with #9991 first

@tacaswell tacaswell added this to the v2.2 milestone Dec 13, 2017
@tacaswell tacaswell requested a review from WeatherGod December 13, 2017 19:59
@eric-wieser
Copy link
Contributor Author

eric-wieser commented Feb 9, 2018

#9991 is in, but I think this will conflict with #10001 too - so again, I plan to delay this one

@eric-wieser eric-wieser force-pushed the lightsource-shading branch from 915e522 to 57fe938 Compare July 12, 2018 06:57
@eric-wieser
Copy link
Contributor Author

Alright, rebased.

@WeatherGod
Copy link
Member

./lib/mpl_toolkits/mplot3d/axes3d.py:1652:9: E303 too many blank lines (2)
1     E303 too many blank lines (2)

flake8 failure

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style issue: Always put a period at the end of a Parameter description, even if it‘s just an Expression like „Data values as 1D arrays.“. (Multiple occurrences)

always disabled when cmap is specified

lightsource : LightSource
The lightsource to use when `shade` is True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if this referenced the LightSource api docs since this isn't a common thing.

Whether to shade the facecolors. Defaults to True. Shading is
always disabled when cmap is specified
lightsource : LightSource
The lightsource to use when `shade` is True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cross ref to the LIghtSource class. Also, would it make sense to give a rough description of what the default light source would be?

This didn't respect the x and y coordinates, so plotting `x{::-1], y{::-1], z[::-1,::-1]` would result in different shading to `x, y, z`.

It also looked super screwy, and could only be triggered if `facecolors="do something wacky"` was passed
@eric-wieser eric-wieser force-pushed the lightsource-shading branch from 57fe938 to ec18ea9 Compare July 13, 2018 16:57
@eric-wieser
Copy link
Contributor Author

PEP8 and periods fixed. Feel free to edit docs in place here

@eric-wieser
Copy link
Contributor Author

@WeatherGod:

cross ref to the LIghtSource class.

Can I do that directly in the parameter types as lightsource : `LightSource` ?

@timhoffm
Copy link
Member

Please use: lightsource : `~matplotlib.colors.LightSource`

@eric-wieser
Copy link
Contributor Author

@timhoffm: Done

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docstring issues to be fixed (sorry to be a bit picky here, but we want to have good looking consistent documentation).

Otherwise looks good.

Minimum and maximum value to map.
shade : bool
Whether to shade the facecolors. Defaults to True. Shading is
always disabled when `cmap` is specified.
Copy link
Member

@timhoffm timhoffm Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*cmap*

We use *cmap* to denote other variables.

https://matplotlib.org/devel/documenting_mpl.html#id3

Whether to shade the facecolors. Defaults to True. Shading is
always disabled when `cmap` is specified.
lightsource : `~matplotlib.colors.LightSource`
The lightsource to use when `shade` is True.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*shade*

Parameters
----------
X, Y, Z : array-like
Data values as 1D arrays
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions should end with a period, even if they are only expressions and not full sentences.

X, Y, Z : array-like
Data values as 1D arrays
color
Color of the surface patches
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period

Whether to shade the facecolors. Defaults to True. Shading is
always disabled when `cmap` is specified.
lightsource : `~matplotlib.colors.LightSource`
The lightsource to use when `shade` is True.

The (optional) triangulation can be specified in one of two ways;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be no text block in a parameters section in numpydoc style. This would be interpreted as further parameters, which doesn't look nice

Please move this block before the parameters section.

@@ -1917,7 +1922,8 @@ def plot_trisurf(self, *args, color=None, norm=None, vmin=None, vmax=None,
Other arguments are passed on to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same text block in parameters section problem. We work around that by summarizing this under a **kwargs parameter:

        **kwargs
            All other keyword argument are passed to 
            `~mpl_toolkits.mplot3d.art3d.Poly3DCollection`.

always disabled when `cmap` is specified.

lightsource : `~matplotlib.colors.LightSource`
The lightsource to use when `shade` is True.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use *shade* to denote other variables.

https://matplotlib.org/devel/documenting_mpl.html#id3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I missed this instance, sorry.

@eric-wieser
Copy link
Contributor Author

@timhoffm: Updated. I'm starting to regret updating the documentation to the new format...

@timhoffm
Copy link
Member

timhoffm commented Sep 6, 2018

I'm starting to regret updating the documentation to the new format...

I'm sorry about that. I know that changing the documentation format is quite a hassle. However, a good and consistent documentation is essential for a complex library like matplotlib. We still have a long way to go, but we have already made some progress with the docs. It's a long-running effort which has to be taken one small step at a time. So thanks again for helping with this.

This is good to go. We just need a second review.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks a lot! This looks like something that could do with a figure test at some point, but I'll leave that until another PR.

@dstansby dstansby merged commit 82a4b24 into matplotlib:master Sep 16, 2018
@anntzer anntzer mentioned this pull request Sep 17, 2018
6 tasks
@eric-wieser eric-wieser deleted the lightsource-shading branch March 23, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants