-
-
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
DataFrame.plot error when both 'color' and 'style' arguments are passed (GH9671) #9674
Conversation
Thanks. In the future, you don't need to open up a new PR. You can push changes to your original pull request and github will pick them up. I made a couple comments inline. Please let me know if you've got any questions or if anything I wrote doesn't make sense. The tests look great! I'm glad you included one that should raise an exception (I always forget these). I just had a few things to make them fit into our test framework. Once you make those changes you can test these specific ones with |
@@ -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: |
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]
…ges as suggested by TomAugspurger
Thanks for your comments Tom. I made the changes you suggested. |
Values from range [1e-7, 5e-7] (for display.precision=7) not displaying 0 anymore
BUG: secondary_y may not show legend properly
BUG: format small floats correctly (GH9764)
@davidbrochart could you rebase on master and add a release note in You can also squash your commits down to one. Let me know if you have any troubles. |
…en both 'color' and 'style' keywords were passed and there was no color symbol in the style strings (this should be allowed)
…chart/pandas into plot_style_fix_and_test
@TomAugspurger I rebased on master and added a release note. Hope this is fine. |
Merged via f00d6bb Thanks @davidbrochart |
closes #9671
self.style
can be a list of strings or a string. If it is a string, we make a list containing that string, so that we only have to deal with a list of strings. We check every element in that list and raise an error if it has a color symbol.The test makes sure that calling
plot()
and passing bothcolor
andstyle
arguments is allowed if there is no color symbol in the style string(s), and that passing bothcolor
andstyle
arguments is not allowed if there is a color symbol in the style string(s). This test is done for a dataframe and for a series.