Skip to content

Modified restrictions on margins method #9459

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 3 commits into from
Oct 19, 2017
Merged

Modified restrictions on margins method #9459

merged 3 commits into from
Oct 19, 2017

Conversation

AtharvaKhare
Copy link
Contributor

@AtharvaKhare AtharvaKhare commented Oct 17, 2017

PR Summary

Modified and added example for matplotlib.axes.Axes.margins().

Fixes #9334.

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

@dstansby dstansby added this to the v2.2 milestone Oct 17, 2017
ax3.margins(x=1, y=0.5)
assert ax3.margins() == (1, 0.5)
ax3.margins(x=-0.2, y=0.5)
assert ax3.margins() == (-0.2, 0.5)
Copy link
Member

Choose a reason for hiding this comment

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

I think these tests would be better if they also asserted the x-lim and y-lim you expect. i.e. assert ax3.get_xlim() == (left, right). That way if anyone monkeys with the internal code this test will catch the inconsistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed 76a2721.

@jklymak
Copy link
Member

jklymak commented Oct 18, 2017

#9463 should fix your docs-python errors. When that gets accepted, you can merge w/ master and this should be good to go if the tests pass (#9463 might take a couple of days). If you need help merging with master, folks here can help.

@AtharvaKhare
Copy link
Contributor Author

AtharvaKhare commented Oct 18, 2017

Please trigger rebuild for circleci.
Is there anything additional to be done by me?

@jklymak
Copy link
Member

jklymak commented Oct 18, 2017

You’ll need to merge the upstream master with your branch. Basically follow the instructions at https://help.github.com/articles/syncing-a-fork/ but where they tell you to checkout master you will checkout flexible-axis-margins. Then push back to github.

@tacaswell
Copy link
Member

Who ever merges this please squash-merge to get rid of the merge from master (or @AtharvaKhare can you rebase this on to current master?).

@jklymak
Copy link
Member

jklymak commented Oct 18, 2017

@AtharvaKhare we can squash-merge if you like. This makes your 6 commits look like one commit and makes the matplotlib commit history much cleaner.

If you'd like yet another bit of git-fu, you can git rebase the six commits into one. I usually do a git log and count how many commits I want to merge (say 6 in your case) and do git rebase -i HEAD~6 (though I always forget if it should be 6 or 7). Then in the editor that should pop up I "squash" the newest entries and pick the oldest entry. You then edit to edit the log entry.

Then you need to git push origin flexible-axis-margins --force to put the new single commit onto github. You need to --force because you are changing history.

There are many guides to this online. http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html.

I sometimes screw it up. A good idea is to make a backup of your repository, then you can start again if you need to. push --force will always overwrite any old mistakes you made.

If you have trouble just ask. This is kind of an optipnal step on your part, but I think "Squash and merge" from our end is risky in case of conflicts...

[as an aside, none of this is actually in our development docs. It might be reasonable to add a short guide outlining the basic git workflows]

@tacaswell
Copy link
Member

It was in our development docs for a while and then was removed by updating gitwash, see matthew-brett/gitwash#13

============
Margins demo
============

Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a small paragraph explaining what the example does?
The title is also not very informative.

Copy link
Contributor Author

@AtharvaKhare AtharvaKhare Oct 18, 2017

Choose a reason for hiding this comment

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

@NelleV Pushed e3280c6. Is it enough or should I elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

Do you mind if I push some changes directly to the branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go ahead.

Axes.set_xmargin and Axes.set_ymargin methods now take values greater
than -0.5. Margins greater than 0 zoom out and margins between -0.5
and 0 zoom in.
Modified `lib/matplotlib/test/test_axes.py::test_margins` to reflect
the changed method.
Added an example for `Axes.margins` at `example/axes_grid1/axes_margins.py`.
@jklymak
Copy link
Member

jklymak commented Oct 18, 2017

@tacaswell Ah OK, it is indeed at http://matplotlib.org/devel/gitwash/development_workflow.html

I admit that I find the heading "Working with Matplotlib source code" a bit obscure and didn't think to check there on a quick skim. I'd have said "Using git and github with Matplotlib source code".

@NelleV
Copy link
Member

NelleV commented Oct 19, 2017

I've extended a bit the documentation of this example, and moved it outside of the axis_gris1 example folder (which is specifically for the toolkit axes_grid1) and into the pyplot_examples.

@AtharvaKhare
Copy link
Contributor Author

@NelleV Thank you!
@tacaswell Do the commits need to be squashed again?

@choldgraf choldgraf merged commit 5eb185f into matplotlib:master Oct 19, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants