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

Skip to content

updated the pyplot fill_between example to elucidate the premise;maki… #10967

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 13 commits into from
Apr 19, 2018

Conversation

bellmj
Copy link
Contributor

@bellmj bellmj commented Apr 6, 2018

…making the chart more readable and removing unnecessary confusing code
This example was changed to two opposing quadratic functions that are highlighted in red for their intersection area, and in yellow for the area between the curves. This example highlights the fill between example better than the previous example, two intersecting sin graphs, because it is very clear what is exactly "between" and "intersecting".
Additionally I removed confusing use of code that I believed distracted from the true purpose of the example: the illustrate the use of fill_between(). Previously to understand the example one had to understand that the nympy.sin() method could be used to generate an array. The updated example can be read more clearly by entry level programmers without the unnecessary documentation lookup.

PR Summary

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

…ng the chart more readable and removing unnecessary confusing code
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! The title needs to change, and I disagree w removing sin; if someone looking at the code can’t guess what sin(x) does when x is an array, then.... use of alpha is great. Tests are failing on line length errors. Please keep under 80 characters long.

@bellmj
Copy link
Contributor Author

bellmj commented Apr 6, 2018

While the arrays issue was one reason for wanting to remove the sin it had more to do with the way the generated chart looked vs the new chart We believe that our example shows a more practical use of the feature, fill_between()

x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 1.2*np.sin(4*np.pi*x)
x = np.arange(-5, 5, 0.01)
Copy link
Member

Choose a reason for hiding this comment

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

Title still needs to be changed (this isn't your fault, but this name is just an error from the conversion to sphinx gallery).

I still think that np.sin is just as useful an example as yours. not sure why you think this is more illustrative - is it just because you lose track of what is y1 and what is y2?

Copy link
Contributor

@anntzer anntzer Apr 6, 2018

Choose a reason for hiding this comment

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

fwiw I prefer the parabolas (because as you say it's easier to keep track of who's who).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll commit the name change

@bellmj
Copy link
Contributor Author

bellmj commented Apr 6, 2018

I'm not sure what I did to make the lgtm analysis fail. Any thoughts?

[2018-04-06 18:58:44] [build] FATAL ERROR: [2018-04-06 18:58:44] [build] Unable 
to find tracer library for Python version 3.6 in /opt/dist/tools 
[2018-04-06 18:58:44] [build] No module named 'semmle' 
[2018-04-06 18:58:44] [build] Supported versions are: 2.7, 3.5 
[2018-04-06 18:58:44] [build] Calling python3 -S 
  /opt/dist/tools/python_tracer.py -v -z all -c
  /opt/out/snapshot/workspace/trap_cache -p 
  /opt/src:/opt/out/snapshot/workspace/venv/lib/python3.6/site-packages -R 
  /opt/src -Y /opt/src/.git/ 
[2018-04-06 18:58:44] [build] Traceback (most recent call last): 
[2018-04-06 18:58:44] [build] File "/opt/buildtools/python/index.py", line 90, 
in <module> [2018-04-06 18:58:44] [build] main() 
[2018-04-06 18:58:44] [build] File "/opt/buildtools/python/index.py", line 87, 
in main 
[2018-04-06 18:58:44] [build] subprocess.check_call(args) 
[2018-04-06 18:58:44] [build] File "/usr/lib/python2.7/subprocess.py", 
line 186, in check_call 
[2018-04-06 18:58:44] [build] raise CalledProcessError(retcode, cmd) 
[2018-04-06 18:58:44] [build] subprocess.CalledProcessError: 
  Command '['python3', '-S', '/opt/dist/tools/python_tracer.py', '-v', '-z',
   'all', '-c', 
  '/opt/out/snapshot/workspace/trap_cache', '-p', 
  '/opt/src:/opt/out/snapshot/workspace/venv/lib/python3.6/site-packages', 
  '-R', '/opt/src', '-Y', '/opt/src/.git/']' returned non-zero exit status 2

@jklymak
Copy link
Member

jklymak commented Apr 6, 2018

I don't care what the file is named. I care about the title that users see!

=============================
Whats New 0.98.4 Fill Between
=============================

bellmj added 4 commits April 17, 2018 13:02
This reverts commit f65ab08.
reverting to the commit before the filename change since this broke the build
@bellmj
Copy link
Contributor Author

bellmj commented Apr 17, 2018

That "should" be correct now

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 for this, I think the modified example looks much better

@dstansby dstansby merged commit 64050ca into matplotlib:master Apr 19, 2018
@dstansby dstansby modified the milestones: v2.2-doc, v3.0 Apr 19, 2018
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.

4 participants