Skip to content

Addition of RC parameters #4218

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

Merged
merged 3 commits into from
Jul 12, 2015
Merged

Addition of RC parameters #4218

merged 3 commits into from
Jul 12, 2015

Conversation

Mrngilles
Copy link
Contributor

Ended the work from PR 2702, and added other RC parameters.
What was done :

  • By @olgabot : Added RC to remove specific spines
  • (Put in its own PR) Added recursive style RC parameter: you can import recursively styles from an other stylesheet
  • (Removed) Made scatter, fill_between, fill_betweenx use color_cycle
  • Added RC to control boxplot parameters, and the associated validation functions when necessary.
  • Added RC to control axis grid display. You can now choose whether you want x, y, or both grid.

@@ -3050,6 +3050,10 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,

.. plot:: mpl_examples/statistics/boxplot_demo.py
"""
if not rcParams['boxplot.whiskers']==1.5:
Copy link
Member

Choose a reason for hiding this comment

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

pep8 issue (space around ==)

@tacaswell tacaswell added this to the next point release milestone Mar 13, 2015
@@ -3616,7 +3690,8 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
if facecolors is not None:
c = facecolors
else:
c = 'b' # the original default
color_cycle = self._get_lines.color_cycle
Copy link
Member

Choose a reason for hiding this comment

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

👎 on scatter using color cycle. This has come up before and the consensus was that scatter should be independent of color cycle because it is as scalar mappable. One of two reasons to use scatter over a plot with no line is if you want to map the color of the markers to an array (the other is to scale the size of the markers (and maybe the rotation?)).

This is also an major API break, if we do want to make scatter sometimes hook into the color cycle it should be done on the color_overhaul branch for the 2.0 release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I did not know about that.

v = float(s)
return v
except:
raise ValueError('not a float')
Copy link
Member

Choose a reason for hiding this comment

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

This should say "not a valid wisker value ['range', float, (float, float)]" or something to that effect.

@Mrngilles
Copy link
Contributor Author

I'm not sure why the last Travis build failed in 2.7 without args... Any idea?
Seems to be a backend related problem... But I'm not sure how this PR is related to this

@tacaswell
Copy link
Member

I kicked it to restart, smelled like a transient failure

On Wed, Jun 17, 2015, 16:51 Gilles Marin notifications@github.com wrote:

I'm not sure why the last Travis build failed in 2.7 without args... Any
idea?


Reply to this email directly or view it on GitHub
#4218 (comment)
.

@WeatherGod
Copy link
Member

It passes now.

@@ -3050,11 +3050,41 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,

.. plot:: mpl_examples/statistics/boxplot_demo.py
"""
if not rcParams['boxplot.whiskers'] == 1.5:
Copy link
Member

Choose a reason for hiding this comment

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

this probably needs a comment explaining why this is being done to prevent future developers from "fixing" this. Also, why the "not" instead of "!="?

# If defined in matplotlibrc, apply the value from rc file
# Overridden if argument is passed
if rcParams['boxplot.whiskers'] != 1.5:
whis = rcParams['boxplot.whiskers']
Copy link
Member

Choose a reason for hiding this comment

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

If I understand this correctly, then a bad situation can arise. If someone has an rc file with a different value for boxplot.whiskers, but explicitly passes in a value for whis, then the rcfile's value takes precedence. That would be incorrect. Why not set the default value of whis to None and test for that?

I have similar concerns for bootstrap because it completely ignores the possibility that the user explicitly sets some value for it.

@@ -2889,11 +2889,11 @@ def xywhere(xs, ys, mask):

return errorbar_container # (l0, caplines, barcols)

def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
positions=None, widths=None, patch_artist=False,
def boxplot(self, x, notch=None, sym=None, vert=None, whis=1.5,
Copy link
Member

Choose a reason for hiding this comment

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

I think you meant to change whis=None

@tacaswell
Copy link
Member

Can you add tests that for all of this? I think a single 5x5 grid png will give enough to cover all of the rcparams

Can you add the tests of the 'default' values in another PR based on current master (so that if this PR changes the defaults we will know)?

@Mrngilles
Copy link
Contributor Author

You want me to write tests for all the added rc, or only the boxplot ones?
When you say a 5x5 grid, you mean a 5x5 grid of axes right?
For the test of the default values, this would mean just plotting without passing optional parameters and make sure we have the good image?

@tacaswell
Copy link
Member

At least the boxplot ones, but if you want to do the other ones as well that would be awesome 👍

Yes, I mean a 5x5 grid of axes. If you can cover all of the rcparams in less that is fine too (5x5 was just the first size that popped into my head, not something carefully considered).

And yes, the idea behind the baseline test is to verify that this does not change anything unless the user explicitly asks for things to be changed (which the last round of changes to boxplot did which was less than great). Now that I type this out, can you start by checking that we do not already have this test?

@Mrngilles
Copy link
Contributor Author

I checked already for the last test. There is a basic one, but it includes bootstrap and sym options. I will include a test_boxplot_no_options to the tests.
Also, using a "5x5" figure would mean testing all the parameters in a single test right? I guess I don't need to write these 30 tests functions, but just want to make sure that I only need one function testing all the parameters.
Edit: I guess that for the boxplot tests, I could make a single figure, as all parameters are different from one another... I will try it this way, and add axes if necessary

@tacaswell
Copy link
Member

Yes, doing it with a single function + single image is the idea. I would
do something like

def _rctest_bxp_helper(ax, rc_dict):
    with rccontext(rc_dict):
        ax.boxplot(...)

def test_all_the_boxplot_rcparams():
    list_of_rcdicts = [ ]
    arr_of_axes = plt.subplots(5, 5).ravel()
    for ax, rc_dict in zip(arr_of_axes, list_of_rcdicts):
        _rctest_bxp_helper(ax, rc_dict)

On Thu, Jul 2, 2015 at 3:26 PM Gilles Marin notifications@github.com
wrote:

I checked already for the last test. There is a basic one, but it includes
bootstrap and sym options. I will include a test_boxplot_no_options to
the tests.
Also, using a "5x5" figure would mean testing all the parameters in a
single test right? I guess I don't need to write these 30 tests functions,
but just want to make sure that I only need one function testing all the
parameters.


Reply to this email directly or view it on GitHub
#4218 (comment)
.

@WeatherGod
Copy link
Member

ping @Mrngilles , this needs a rebase. This also blocks #4669.

Added xtick.position and ytick.position to rcsetup.py

trying to fix Travis CI failure on 2.6

Removed x-y position parameter from rc default dic

Added style rcParam + stylesheet recursion

scatter, fill_between and fill_betweenx use color_cycle

Added rcParameters for boxplot + validations functions

Added rcParameter to choose grid axis display

Comment tweaks

added boxplot.flierprops + line length fixes

fix: unable to get substyles from path or URL

removed boxplot.fliersymbol because not needed

Fixed boxplot checks

spine removing modified + removed : from docstring

removed color_cycle from scatter, fill_between, fill_betweenx

Original behaviour of axes.grid + working rc axes.grid.orientation

Fixed the get_substyles function to accept dictionnaries

Fix PEP8 + OrderedDict issues in Travis

Modified how we get rcParams in the boxplot method

tried fixing test issues + pep8

fix travis for patch_artist linestyle issue

removed the style rcParam to put it in an other PR

used setdefault function + validation function + Error message

fixed pep8 error

fixed pep8 error (again)

Comments and style fixes

Fixed whiskers and bootstrap rcParams use

Added tests for boxplot rc parameters and fixes

added spine rc parameter test

added test for axes.grid.axis rc parameter + typo fix in spines test

Typo fix
@Mrngilles
Copy link
Contributor Author

Rebased. Hope this works, but the tests should at least be okay

@Mrngilles
Copy link
Contributor Author

I guess the test had an other unexpected issue... I'm not sure if that's my code or if the problem was already there, but it seems it already happened before.

@jenshnielsen
Copy link
Member

Looks like the last test failure was unrelated issue. I have restarted the test

meanline=False, showmeans=False, showcaps=True,
showbox=True, showfliers=True, boxprops=None, labels=None,
meanline=None, showmeans=None, showcaps=None,
showbox=None, showfliers=None, boxprops=None, labels=None,
Copy link
Member

Choose a reason for hiding this comment

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

I think the doc string (below) needs update to reflect these changes

@jenshnielsen
Copy link
Member

It looks good to me, I think this only needs an updated docstring for boxplot to reflect the changes

tacaswell added a commit that referenced this pull request Jul 12, 2015
ENH: Addition of RC parameters
@tacaswell tacaswell merged commit ecce9a1 into matplotlib:master Jul 12, 2015
@tacaswell
Copy link
Member

@olgabot @Mrngilles Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants