Skip to content
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

mep12 on quiver_demo.py #4833

Merged
merged 9 commits into from Aug 4, 2015
Merged

mep12 on quiver_demo.py #4833

merged 9 commits into from Aug 4, 2015

Conversation

ericmjl
Copy link
Contributor

@ericmjl ericmjl commented Jul 30, 2015

No description provided.

1,
r'$1 \frac{m}{s}$',
fontproperties={
'weight': 'bold'})
Copy link
Member

Choose a reason for hiding this comment

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

autopep8 gone awry?

Copy link
Member

Choose a reason for hiding this comment

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

still need to fix the autopep8 issue above.

@jenshnielsen jenshnielsen added the MEP: MEP12 gallery and examples improvements label Jul 30, 2015
dx, dy = r - l, t - b
axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy])
plt.axis([l - 0.05 * dx, r + 0.05 * dx, b - 0.05 * dy, t + 0.05 * dy])
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this step is creating a 5% margin. Unfortunately, it does not look like you would get the same effect if you do plt.margins(0.05) instead of the previous 3 lines involving axis()... I wonder if that is a bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, I would not add spaces around the asterisk.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, not a bug as what this code is doing is not exactly the same as what margins() does. I can get it to be fairly close using plt.margins(0.05, tight=False), but it isn't the same. So I guess we will just leave it as is.

As for the spaces around the asterisks, it probably was clearer before. This is the danger of autopep8! The only time I use it is when I am reworking someone else's code who has very little experience with proper code formatting. The intent is not that the autopep8 version gets into version control, the intent is to make it easier for me to read so that I can rewrite it better. Even then, I don't let it run with all of the options on.

# 6
plt.figure()
M = np.zeros(U.shape, dtype='bool')
M[U.shape[0] / 3:2 * U.shape[0] / 3, U.shape[1] / 3:2 * U.shape[1] / 3] = True
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO the line looks better without the spaces around the operators.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. In this version, I see the 3:2 grouped together, even though they are separate. If anything, I would instead have each slice on their own lines. This would also keep it under 80 chars.

@WeatherGod
Copy link
Member

PEP8 failures:

/home/travis/build/matplotlib/matplotlib/examples/pylab_examples/quiver_demo.py:84:15: E203 whitespace before ':'
/home/travis/build/matplotlib/matplotlib/examples/pylab_examples/quiver_demo.py:84:46: E203 whitespace before ':'

And I agree with that error. What I recommend doing is to split the indexing across two lines at the comma. That will make it more readable. In addition, you can use parentheses to help visually group things if it helps, but sometimes parentheses just add visual clutter.

You also still have some cleanup from the autopep8 gone awry to deal with.

@ericmjl
Copy link
Contributor Author

ericmjl commented Jul 31, 2015

Got it, I will try parentheses and splitting the lines. And avoid autopep8 for this file.

@ericmjl
Copy link
Contributor Author

ericmjl commented Aug 4, 2015

Looks like it's pep8 issues. Gonna fix.

WeatherGod added a commit that referenced this pull request Aug 4, 2015
@WeatherGod WeatherGod merged commit 1383295 into matplotlib:master Aug 4, 2015
@ericmjl ericmjl deleted the mep12_quiver_demo.py branch August 4, 2015 13:53
@QuLogic QuLogic added this to the v1.5.0 milestone Nov 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MEP: MEP12 gallery and examples improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants