-
Notifications
You must be signed in to change notification settings - Fork 286
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
Added line styling keyword arguments to plot outline functions #1734
Conversation
👍 for the concept ... I've hacked this together several times but never got round to polishing and submitting a PR. There's an inconsistency in the quickplot vs. plot interfaces that needs sorting. The quickplot function takes |
My thinking was that iris.plot outline is an odd one out, in that it doesn't wrap another function in the same way that iris.plot pcolor wraps pyplot's pcolor function. I figured the quickplot outline function is a wrapper for iris.plot outline so it needn't handle all of the kwargs, but iris.plot outline uses pyplot's pcolormesh to draw the outline of a grid which is more specific functionality than pcolormesh provides. Essentially, my concern was that if we were to use the Could you explain why you think the interfaces in plot and quickplot should be the same? |
I think you have a good point @Jozhogg. Allowing arbitrary arguments to be passed through to I suggest perhaps the However, since we are restriciting arguments to |
Thanks for the help @ajdawson and @rhattersley. I've made the functions in Unfortunately, |
No problem, I didn't check before I suggested it. |
The API makes much more sense now - thanks both of you. |
@@ -801,10 +801,14 @@ def outline(cube, coords=None): | |||
element is the horizontal axis of the plot and the second element is | |||
the vertical axis of the plot. | |||
|
|||
See :func:`matplotlib.pyplot.pcolormesh` for details of other valid keyword | |||
arguments. |
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 docstring needs updating.
Is this documentation OK? I was a little unsure what guidelines to follow. |
At a glance it looks fine - thanks. The docstrings aren't completely consistent in Iris so it's fair enough to be unsure! I'll build the docs and double-check how they appear... |
I think normally the part after the colon would try and describe the type of the argument and the line underneath would describe what the argument is for. The actual types of these arguments can be one of many, for example matplotlib color definitions can be strings with a predefined letter indicating a color, strings containing a hexadecimal RGB value, or a tuple of RGB values etc. You could describe the type of the color argument as "any matplotlib color` and the linestyle as "any matplotlib line style", in fact the matplotlib docs do this. |
👍 ... I didn't push that because I was trying to keep my attention-to-detail habit under control, but maybe I should have so @ajdawson doesn't have to play the bad cop. Sorry @ajdawson 😒 |
No problem @rhattersley! Perhaps it is I who needs to get an attention-to-detail habit under control... |
It's OK - I always knew the day would come when I would have to start learning to properly document my code! How does attempt number 2 look? |
@@ -801,10 +801,15 @@ def outline(cube, coords=None): | |||
element is the horizontal axis of the plot and the second element is | |||
the vertical axis of the plot. | |||
|
|||
* color: any matplotlib color. | |||
|
|||
* linewidth: float value for width of outline. |
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 combines the type of the argument with the meaning of the argument. The preferred form these days is more like:
* color: None or mpl color
The color of the cell outlines. If None, the rc setting (which one???) is used by default.
* linewidth: None or number
The width of the lines showing the cell outlines. If None, the default width in lines.linewidth(???) in matplotlibrc is used.
NB. This could do with a more consistent description of the behaviour when None. (Or we just ignore it... 😑 )
Was able to confirm the behaviour with None. Thanks for the help @rhattersley |
The content looks good now, thanks. 👍 Unless @ajdawson's got any more tweaks to suggest then this just needs squashing into a single commit. If you need help with that I'm happy to do it remotely, but it'd probably be easiest to grab someone from the team who's actually in the office. |
I do have one further item to discuss, sorry! I think you've actually changed the default behaviour of the function by setting the default value of the For color there is no issue because the previous version explicitly set the colour to black. |
Completely! Eagle-:eyes: @ajdawson strikes again! 👍 |
Good spot! I'll go ahead address that and ask somebody at the office about squashing commits. Thanks both. |
b89973a
to
b0ac2e6
Compare
Thanks for addressing @ajdawson's issue and squashing your commits. This looks to be ready to 🚢 (although I said that before!) ... 👍 |
👍 |
Added line styling keyword arguments to plot outline functions
Well done @Jozhogg 🎉 |
Added the option to provide 'edgecolors' and 'linewidth' keywords to iris.plot and iris.quicklpot outline functions.