Skip to content

example file for making a bar of pie chart #11865

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 1 commit into from
Aug 16, 2018

Conversation

pjk645-zz
Copy link

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

@@ -0,0 +1,97 @@
"""
=========
Copy link
Member

Choose a reason for hiding this comment

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

This will fail to build because the = must be the right length...

Copy link
Author

Choose a reason for hiding this comment

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

I was parroting other examples. What is the correct length?

Copy link
Member

Choose a reason for hiding this comment

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

As long as the title (or longer I think is OK)

bar_height = sum([item.get_height() for item in ax2.patches])

# draw top connecting line
x = r*np.cos(math.pi/180*theta2)+center[0]
Copy link
Member

Choose a reason for hiding this comment

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

Just use np.pi to save the math import.

Copy link
Member

Choose a reason for hiding this comment

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

falke8 will complain about the spacing here. r * np.cos(np.pi / 180 * theta2) + center[0]. Yes, its arbitrary, but its a good to have a standard so code looks the same throughout. http://flake8.pycqa.org/en/latest/user/error-codes.html

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I made the changes. I ran flake8 and it didn't seem to care about the math formatting. Just an fyi.

Copy link
Author

Choose a reason for hiding this comment

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

update on that, I think it checks for consistency: when there were no spaces in the math it was happy. Then when I put spaces around most mathematical operators it wanted them around all of them and was spitting out problems.

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 a lot for this. It looks like it'll be great. Looks like it'll take a couple of tries to pass the CI tests. Look under Travis CI for flake8 errors (or install flake8 and run flake8 examples/pie_and_polar_charts/bar_of_pie.py. Note that to pass Flake8, you'll have to add an exception to .flake8 for E402 because this code has an import near the bottom. And look under the CI for the doc builds for errors and to make sure your example looks the way you'd like.

Please use a more descriptive title, and a bit of description in the PR description.

Thanks again!

@jklymak jklymak added this to the v2.2-doc milestone Aug 16, 2018
@pjk645-zz pjk645-zz changed the title initial commit example file for making a bar of pie chart Aug 16, 2018
@pjk645-zz
Copy link
Author

pjk645-zz commented Aug 16, 2018

I'm not sure why this is failing the Travis CI. Anyone have any ideas? It is passing flake8 on my computer except for the E402 exception.

@jklymak
Copy link
Member

jklymak commented Aug 16, 2018

./examples/pie_and_polar_charts/bar_of_pie.py:88:1: E402 module level import not at top of file
E402 module level import not at top of file

You need to add the exception in .flake8 for this file.

Otherwise looks good.

https://12490-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/gallery/pie_and_polar_charts/bar_of_pie.html#sphx-glr-gallery-pie-and-polar-charts-bar-of-pie-py

@pjk645-zz
Copy link
Author

Okay, thanks. I didn't pick up on that earlier.

.flake8 Outdated
@@ -6,6 +6,7 @@ ignore =
E111, E114, E115, E116, E122, E124, E125, E127, E128, E129, E131,
E265, E266,
E305, E306,
E402,
Copy link
Member

Choose a reason for hiding this comment

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

Not here - add a per-file exception. See the other example files below...

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 a lot. Approve conditional on CI passing...

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.

Looks good. Anyone can merge after CI pass. Maybe the commits should be squashed.

@jklymak
Copy link
Member

jklymak commented Aug 16, 2018

@pjk645 one more chore and then you'll have done it all..

First, back your branch up (git checkout bar_of_pie; git checkout -b bar-of-pie-backup; git checkout bar_of_pie)

Run git log and find the last commit before your first commit. Copy the commit id (i.e. df545a0433) and do:

git rebase -i xxxxxxxxxxx

Your editor should open and you "pick" the first commit and "squash" the following five entries. Save that file, and then the editor will open again and you can edit the single commit message.

Then git push origin bar_of_pie --force (the --force is why we back up just in case we make a mistake).

@pjk645-zz
Copy link
Author

Hopefully, I did that correctly...

Thanks for the guidance

@jklymak jklymak merged commit 93879f8 into matplotlib:master Aug 16, 2018
@lumberbot-app
Copy link

lumberbot-app bot commented Aug 16, 2018

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.3-doc
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 93879f8c557358b4e34212c2ee39c6f5bc5692d7
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #11865: example file for making a bar of pie chart'
  1. Push to a named branch :
git push YOURFORK v2.2.3-doc:auto-backport-of-pr-11865-on-v2.2.3-doc
  1. Create a PR against branch v2.2.3-doc, I would have named this PR:

"Backport PR #11865 on branch v2.2.3-doc"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@jklymak
Copy link
Member

jklymak commented Aug 16, 2018

Thanks a lot for your patience with the process @pjk645 and congrats on your first contribution!

@jklymak
Copy link
Member

jklymak commented Aug 16, 2018

OK, I don't feel this is so urgent as to go through the backport rigamarole. Undoubtably just .flake8, but...

@jklymak jklymak modified the milestones: v2.2-doc, v3.1 Aug 16, 2018
@QuLogic QuLogic modified the milestones: v3.1, v3.0 Aug 17, 2018
@pjk645-zz pjk645-zz deleted the bar_of_pie branch August 19, 2018 20:53
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.

5 participants