-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
VIS: Allow 'C0'-like plotting for plotting colors #15516 #15873
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
Changes from 1 commit
4003d1c
e249722
dcb4cb0
3cb9e0b
9d15e7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,12 @@ def test_plot(self): | |
result = ax.get_axes() # deprecated | ||
self.assertIs(result, axes[0]) | ||
|
||
def test_mpl2_color_cycle_str(self): | ||
colors = ['C' + str(x) for x in range(10)] | ||
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 add the issue number as a comment |
||
df = DataFrame(randn(10, 3), columns=['a', 'b', 'c']) | ||
for c in colors: | ||
_check_plot_works(df.plot, color=c) | ||
|
||
def test_color_and_style_arguments(self): | ||
df = DataFrame({'x': [1, 2], 'y': [3, 4]}) | ||
# passing both 'color' and 'style' arguments should be allowed | ||
|
@@ -1600,6 +1606,10 @@ def test_line_colors(self): | |
self._check_colors(ax.get_lines(), linecolors=['red'] * 5) | ||
tm.close() | ||
|
||
ax = df.plot(color='C0') | ||
self._check_colors(ax.get_lines(), linecolors=['C0']) | ||
tm.close() | ||
|
||
# GH 10299 | ||
custom_colors = ['#FF0000', '#0000FF', '#FFFF00', '#000000', '#FFFFFF'] | ||
ax = df.plot(color=custom_colors) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,10 +217,13 @@ def _maybe_valid_colors(colors): | |
# check whether each character can be convertable to colors | ||
maybe_color_cycle = _maybe_valid_colors(list(colors)) | ||
if maybe_single_color and maybe_color_cycle and len(colors) > 1: | ||
msg = ("'{0}' can be parsed as both single color and " | ||
"color cycle. Specify each color using a list " | ||
"like ['{0}'] or {1}") | ||
raise ValueError(msg.format(colors, list(colors))) | ||
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. comment here about what you are doing |
||
if color[0] == 'C' and len(color) == 2: | ||
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 could in theory break if 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 causes a In matplotlib, passing |
||
colors = [colors] | ||
else: | ||
msg = ("'{0}' can be parsed as both single color and " | ||
"color cycle. Specify each color using a list " | ||
"like ['{0}'] or {1}") | ||
raise ValueError(msg.format(colors, list(colors))) | ||
elif maybe_single_color: | ||
colors = [colors] | ||
else: | ||
|
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.
can you put a pointer into mpl docs (or pandas docs) about these color.