-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Property Cycling #4686
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
[WIP] Property Cycling #4686
Changes from 1 commit
d08c627
e3c0951
160401b
6b2223d
0c1e609
61d10f9
e356972
68f0afb
c806726
9965f5f
5fa07f2
98fb775
f443629
648d3ea
2e7b6a5
a1b822f
6df7829
871d616
e7786d0
153ef67
8ce4797
f3e8394
6b5a6a5
c72a74f
53f1ff2
9a31950
55bf053
44f74e3
5a3ce17
9848661
63d6321
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
* New rcparam 'axes.style_cycle' * Deprecate rcparam 'axes.color_cycle' * 'axes.style_cycle' can be a cycler object or string repr * Enables setting of just about any property
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern | ||
from matplotlib.colors import is_color_like | ||
|
||
from cycler import cycler, Cycler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I have my paths and/or directory structure set up wrongly, or should this read from cycler.cycler import cycler, Cycler ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh nevermind my path problem, I had the path pointing to the directory containing the repo rather than the repo itself... |
||
|
||
#interactive_bk = ['gtk', 'gtkagg', 'gtkcairo', 'qt4agg', | ||
# 'tkagg', 'wx', 'wxagg', 'cocoaagg', 'webagg'] | ||
# The capitalized forms are needed for ipython at present; this may | ||
|
@@ -299,6 +301,12 @@ def validate_color(s): | |
|
||
raise ValueError('%s does not look like a color arg%s' % (s, msg)) | ||
|
||
def deprecate_axes_colorcycle(value): | ||
warnings.warn("axes.color_cycle is deprecated. Use axes.style_cycle " | ||
"instead. Will be removed in 2.1.0") | ||
return validate_colorlist(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this get called from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I forgot to add that in as the validator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, okay, this just wraps around the validator... hmm, why do it this way then and not as a decorator for Also what do you think about setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @OceanWolf, We don't decorate the validate_colorlist() function because it is a perfectly valid function on its own for validating a list of colors, and so it could be used elsewhere in contexts that have nothing to do with As for setting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with the first point, but on the second you misunderstand me, I didn't mention setting I find it good practice to work around the deprecated stuff as early, aka as high up as possible in the codebase, rather then let it filter through to the deeper level code, as I see happens just above @tacaswell's comment "Should probably tag next version of cycler". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to have a very long deprecation cycle, at least a couple I could also be convinced that it should never be removed and keeping an On Sat, Aug 15, 2015, 3:01 PM OceanWolf notifications@github.com wrote:
|
||
|
||
|
||
|
||
def validate_colorlist(s): | ||
'return a list of colorspecs' | ||
|
@@ -310,6 +318,25 @@ def validate_colorlist(s): | |
msg = "'s' must be of type [ string | list | tuple ]" | ||
raise ValueError(msg) | ||
|
||
def validate_cycler(s): | ||
'return a cycler object from a string repr or the object itself' | ||
if isinstance(s, six.string_types): | ||
try: | ||
# TODO: We might want to rethink this... | ||
cycler_inst = eval(s, {'cycler': cycler, 'Cycler': Cycler}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exciting! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give an example of passing a string to this function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would look exactly like how you would create cycler objects in code,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, of course, because the Could we find a simpler way of passing in a cycle as a string? Asking the user to pass in code as a param feels bad. How about:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we still would have to parse it. By having users pass in the python This is also the repr of a Cycler so it is super easy for users to generate On Sat, Aug 15, 2015 at 1:40 AM OceanWolf notifications@github.com wrote:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I see that, it just feels messy, a config file shouldn't contain code... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It already does contain code, On Sat, Aug 15, 2015 at 2:07 AM OceanWolf notifications@github.com wrote:
|
||
except BaseException as e: | ||
raise ValueError("'%s' is not a valid cycler construction: %s" % | ||
(s, e)) | ||
elif isinstance(s, Cycler): | ||
cycler_inst = s | ||
else: | ||
raise ValueError("object was not a string or Cycler instance: %s" % s) | ||
|
||
# TODO: apply validation to the cycled elements | ||
# probably doable via traitlets | ||
|
||
return cycler_inst | ||
|
||
def validate_stringlist(s): | ||
'return a list' | ||
if isinstance(s, six.string_types): | ||
|
@@ -750,6 +777,11 @@ def __call__(self, s): | |
'axes.color_cycle': [['b', 'g', 'r', 'c', 'm', 'y', 'k'], | ||
validate_colorlist], # cycle of plot | ||
# line colors | ||
# This entry can be either a cycler object or a | ||
# string repr of a cycler-object, which gets eval()'ed | ||
# to create the object. | ||
'axes.style_cycle': [cycler('color', 'bgrcmyk'), | ||
validate_cycler], | ||
'axes.xmargin': [0, ValidateInterval(0, 1, | ||
closedmin=True, | ||
closedmax=True)], # margin added to xaxis | ||
|
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.
Should probably return an empty dict?