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

Consistent grid sizes in streamplot. #2700

Merged
merged 1 commit into from Jan 1, 2014

Conversation

ajdawson
Copy link
Contributor

This PR addresses #2653. The grid size used by streamplot() for density=1 was 30x30 (not 25x25 as stated in the docstring) but for density=(1, 1) it was 25x25. This PR changes the base grid size for both density specification types to 30x30, since this is the grid size currently used for the default value of the density argument.

I modified two tests that use a vector density specification so that the resulting test plots are the same. I saw no need for new test images taking up space in the repository.

@@ -28,7 +28,8 @@ def test_linewidth():
X, Y, U, V = velocity_field()
speed = np.sqrt(U*U + V*V)
lw = 5*speed/speed.max()
plt.streamplot(X, Y, U, V, density=[0.5, 1], color='k', linewidth=lw)
df = 25. / 30.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add a note here. Something like:

    df = 25. / 30.  # Compatibility factor for old test image

@tonysyu
Copy link
Contributor

tonysyu commented Dec 30, 2013

Minor comments above. Otherwise 👍

@ajdawson
Copy link
Contributor Author

Thanks for the quick review @tonysyu, I've addressed your comments. I overwrote the previous commit since the changes were few and minor, hope that is OK.

@tonysyu
Copy link
Contributor

tonysyu commented Dec 30, 2013

Thanks. This looks ready to merge, but I don't actually have the power of the green button so it'll have to wait for a core-dev.

@efiring
Copy link
Member

efiring commented Dec 31, 2013

I don't want to be too fussy when something might be ready to go, but wouldn't it be better to update the test images than to put "compatibility factors" in the tests?

@ajdawson
Copy link
Contributor Author

I don't know if it would be better actually. It is just as simple to slightly modify the tests and avoid having to commit new test images. They could be described differently in the comments of course, I'm not sure I like the term "compatibility factor". They could be described as factor necessary to get a 25x25 grid etc.

@tacaswell
Copy link
Member

The naming is odd, but I think changing the test this way is a feature, not a bug, as it will catch more issues than testing density=1 will.

A bigger problem is that the grid dimension is hard coded, it should really be a kwarg. @ajdawson would you be interested/willing to make that change as well (in a different PR against master)?

@efiring
Copy link
Member

efiring commented Dec 31, 2013

I don't see any need for another kwarg; density is already controlling this underlying parameter (assuming you are referring to "30", @tacaswell). One might argue that instead of a "density" kwarg, there should have been a "grid" kwarg, defaulting to (30, 30), perhaps with the dreaded rcParam to set the default.

@tacaswell
Copy link
Member

Sorry, Eric is right, I wrote that last comment to early and did not fully grasp what density was doing.

It would be better to replace it with 'gridsize' or some such which directly sets nx and ny to make it clearer what is going on, but that is a major api change.

This looks fine to me +1.

efiring added a commit that referenced this pull request Jan 1, 2014
Consistent grid sizes in streamplot.
@efiring efiring merged commit 9be5ac4 into matplotlib:master Jan 1, 2014
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.

None yet

4 participants