Add keymap (default: G) to toggle minor grid.#6875
Add keymap (default: G) to toggle minor grid.#6875tacaswell merged 4 commits intomatplotlib:masterfrom
Conversation
lib/matplotlib/rcsetup.py
Outdated
| 'keymap.quit': [['ctrl+w', 'cmd+w', 'q'], validate_stringlist], | ||
| 'keymap.quit_all': [['W', 'cmd+W', 'Q'], validate_stringlist], | ||
| 'keymap.grid': [['g'], validate_stringlist], | ||
| 'keymap.grid_both': [['G'], validate_stringlist], |
There was a problem hiding this comment.
Is it normal that it is 'keymap.grid_both' here while it is 'keymap.grid_minor' anywhere else in the commit?
There was a problem hiding this comment.
no, that's a typo...
If either minor grid is on, turn both of them off. Otherwise, turn all
major and minor grids on (it usually doesn't make sense to have the
minor grids only).
Also change the behavior of `keymap.grid` ("g") to synchronize the grid
state of both axes. Otherwise, if starting from only grids in one
direction (`plt.plot(); plt.grid(axis="x")`), "g" switches between only
`x` grid and only `y` grid, which is unlikely to be the expected
behavior.
|
Actually, after some more thought, I think I'll prefer another behavior for |
6fa0fd1 to
e8de04c
Compare
|
How the grids cycle through (x,y): (off, off), (on, on), (on, off), (off, on) ? This could probably be generalized to 3d in a strait forward way. |
|
They switch both (which comes from the behavior of |
|
Also... there are no minor grids/ticks in mplot3d (at this point, that is). On Mon, Aug 1, 2016 at 12:29 PM, Antony Lee notifications@github.com
|
|
Implemented @tacaswell's suggestion. I chose the order (none)->(x)->(xy)->(y), so that one can easily switch from both-on to both-off and vice versa by typing "g/G" twice, which I think may be more user friendly. |
lib/matplotlib/backend_bases.py
Outdated
| else: | ||
| ax.grid(x_state, which="both", axis="x") | ||
| ax.grid(y_state, which="both", axis="y") | ||
| canvas.draw() |
|
LGTM modulo an entry in whats_new. |
d7d940f to
0c3937c
Compare
|
Sorry I'm late to the party. I know it is a lot of work, but can you add a tool or modify |
|
@anntzer if you have any questions regarding how to do it i'm happy to help |
|
How can I test my (TBD) implementation in the new API? |
|
take a look at |
1fd07ae to
a02b264
Compare
|
Done. What's the status of MEP22? It's certainly a nicer API than the huge switch-based dispatch in key_press_handler... |
|
MEP22 is already merged but not completed, we are waiting for MEP27 to land, to modify all the backends. PRs are welcome! |
|
@anntzer can you correct the PEP8 problems? |
a02b264 to
32187df
Compare
|
done |
|
Cycled to rerun with current master and fix travis pyparsing issue |
|
👍 from |
doc/users/navigation_toolbar.rst
Outdated
| Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse | ||
| Toggle grid **g** when mouse is over an axes | ||
| Toggle major grid **g** when mouse is over an axes | ||
| Toggle major and minor grid **G** when mouse is over an axes |
There was a problem hiding this comment.
Here you say "major and minor grids", but in the api_changes, you say that "G" will toggle minor grids.
|
Not totally sold on the naming because it is called "minor", but it impacts both minor and major. |
| # Bail out (via ValueError) if minor grids are not in a uniform state. | ||
| x_state, y_state = ( | ||
| cycle[(cycle.index((x_state, y_state)) + 1) % len(cycle)]) | ||
| return x_state, y_state, "both" |
There was a problem hiding this comment.
This is the only thing that is still confusing me. The documentation and descriptions all say that it would be minor grids, but it really is both minor and major, right? Not a reason to hold things up, really -- just want to make sure I understand and see if tweaks to the documentation is needed.
There was a problem hiding this comment.
Basically it toggles the minor grids, but if it would turn on a minor grid while the corresponding major grid is off, then it also turns on the major grid, because it typically doesn't make much sense to have just the minor grid.
If you have a better suggestion for the docs I'm happy to take it...
There was a problem hiding this comment.
Ok, I think I understand now. So it doesn't toggle both major and minor in lockstep. If the major grid is already on, then pressing 'G' won't do anything to the major grid, right? But if the major grid is off, then both of them are turned on/off?
|
Note to self (or whoever wants to take over, should be easy enough): this implementation does not switch off the minor grids when the major grids are turned off, when it should probably do so. |
|
Small PR? On Aug 25, 2016 7:18 PM, "Antony Lee" notifications@github.com wrote:
|
|
Let's see whether playing the waiting game will get someone else to volunteer :) |
|
@anntzer that is not a game I would bet on winning 😜 |
If either minor grid is on, turn both of them off. Otherwise, turn all
major and minor grids on (it usually doesn't make sense to have the
minor grids only).
Also change the behavior of
keymap.grid("g") to synchronize the gridstate of both axes. Otherwise, if starting from only grids in one
direction (
plt.plot(); plt.grid(axis="x")), "g" switches between onlyxgrid and onlyygrid, which is unlikely to be the expectedbehavior.
See #6616.