-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add keymap (default: G) to toggle minor grid. #6875
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
Conversation
@@ -1313,6 +1313,7 @@ def validate_animation_writer_path(p): | |||
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
else: | ||
ax.grid(x_state, which="both", axis="x") | ||
ax.grid(y_state, which="both", axis="y") | ||
canvas.draw() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to draw_idle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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 |
@@ -99,7 +99,8 @@ Close all plots **shift** + **w** | |||
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse | |||
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly.
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 onlyx
grid and onlyy
grid, which is unlikely to be the expectedbehavior.
See #6616.