-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.plot error when both 'color' and 'style' arguments are passed (GH9671) #9674
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
Closed
davidbrochart
wants to merge
15
commits into
pandas-dev:master
from
davidbrochart:plot_style_fix_and_test
Closed
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fe39d3c
Fix for issue #9671
07fff67
Added test for bug fix of issue #9671
davidbrochart 6d4b37f
Merge remote-tracking branch 'upstream/master' into HEAD
davidbrochart 72c5bc1
Made a separate test called test_color_and_style_arguments, made chan…
davidbrochart 025de9d
BUG: Fix for #9764
tomazberisa e375dd7
TST: Test for #9764 fix
tomazberisa 86a1404
TST: Test saves and restore context (#9764)
tomazberisa 7857c43
CLN: Test code cleanup (#9764)
tomazberisa ce988b4
DOC: Update whatsnew for 0.16.1 (#9764)
tomazberisa 2af2044
Merge pull request #9812 from sinhrks/sec_legend
e9179fe
BUG: DataFrame.equals should not care about block order (GH #9330)
dsm054 1fafe76
Merge pull request #9806 from tomazberisa/df-display-bug
shoyer 94ec6c3
Fixed bug #9671 where 'DataFrame.plot()' raised an error when both 'c…
b00da07
DOC: Update whatsnew for 0.16.1 (#9671)
davidbrochart 2c56676
Merge branch 'plot_style_fix_and_test' of https://github.com/davidbro…
davidbrochart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -991,6 +991,18 @@ def test_plot(self): | |
df = DataFrame({'x': [1, 2], 'y': [3, 4]}) | ||
with tm.assertRaises(TypeError): | ||
df.plot(kind='line', blarg=True) | ||
try: | ||
df.plot(color = ['red', 'black'], style = ['-', '--']) | ||
df['x'].plot(color = 'red', style = '-') | ||
except: | ||
self.fail("Calling 'plot()' on a dataframe/series and passing both 'color' and 'style' arguments should be allowed if there is no color symbol in the style string(s)") | ||
try: | ||
df.plot(color = ['red', 'black'], style = ['k-', 'r--']) | ||
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 one should raise and exception, so you can use the with tm.assertRaises(ValueError):
df.plot(color = ['red', 'black'], style = ['k-', 'r--']) so that the test passes if a ValueError is raised, and fails if it doesn't. |
||
df['x'].plot(color = 'red', style = 'k-') | ||
except: | ||
pass | ||
else: | ||
self.fail("Calling 'plot()' on a dataframe/series and passing both 'color' and 'style' arguments should raise an error if there is a color symbol in the style string(s)") | ||
|
||
df = DataFrame(np.random.rand(10, 3), | ||
index=list(string.ascii_letters[:10])) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Instead of wrapping the code in
try
/except
plots, just call the function.ax = df.plot(color=['red', 'black'], style=['-', '--'])
and then make sure the color and styles match what's expected.You can get the actual linestyle with
result = [line.get_linestyle() for line in ax.lines]
Then compare that to the expected with
self.assertEqual(result, ['-', '--'])
Same thing for the colors,
[line.get_color() for line in ax.lines]