-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: repair 'style' kwd handling in DataFrame.plot (#21003) #33821
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 11 commits
cf9b892
20b8b4b
fe8dbeb
12e1d10
948ebab
40d673b
04edda5
dc9c9cf
97ec52c
d14490f
97ae5ae
219d8d5
0c45813
18c1f20
758576b
2c45b97
b949814
ca39eb5
59ff00b
5d63c46
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 |
---|---|---|
|
@@ -204,6 +204,23 @@ def test_color_and_style_arguments(self): | |
with pytest.raises(ValueError): | ||
df.plot(color=["red", "black"], style=["k-", "r--"]) | ||
|
||
def test_color_and_marker(self): | ||
# GH21003 - code sample from 2018-05-10 is equivalent to this test | ||
df = DataFrame(np.random.random((7, 4))) | ||
# combining a color string and a marker letter should be allowed | ||
df.plot(color="green", style="d") # d for diamond | ||
|
||
def test_color_list_and_marker(self): | ||
# GH21003 - code sample from 2020-04-23 is equivalent to this test | ||
df = DataFrame(np.random.random((7, 4))) | ||
color_list = ["yellow", "red", "green", "blue"] | ||
ax = df.plot(color=color_list, style="d") | ||
# Before this patch was introduced, the previous line of code resulted | ||
# in a plot where each individual line was assigned a list of colors: | ||
# ax.lines[i].get_color() == ['yellow', 'red', 'green', 'blue'] | ||
# which resulted in a ValueError when plt.draw() was called. | ||
assert [line.get_color() for line in ax.lines] == color_list | ||
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. same here, also use 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 point! This will introduce lots of duplicate code between the tests 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. Is it more readable to test these four combinations of 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 think this will work in one test? assert [line.get_color() for line in ax.lines] == color_list
assert all(line.get_marker() == 'd' for line in ax.lines) 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. To be honest, i would prefer to combine both of your tests, something like this @pytest.mark.parametrize("color, output_color_list",
[('green', ['green'] * 4),
(['yellow', 'red', 'green', 'blue'], ['yellow', 'red', 'green', 'blue'])
])
def test_color_and_marker(self, color, output_color_list):
df = DataFrame(np.random.random((7, 4)))
ax = df.plot(color=color, style="d")
assert [line.get_color() for line in ax.lines] == output_color_list
assert all(line.get_marker() == 'd' for line in ax.lines) And regarding 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. As I said,
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. so it's jupyter notebook, have you tried to shut down the notebook and restart? and then import? 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. No, this is the IPython Console in Spyder. Restarting Spyder didn't help. 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.
Anaconda prompt stack trace
I've seen this error before, mentioned on April 27 in this thread but I don't remember how I resolved it. 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. emm, have no idea, i really think
would solve the issue if you already merge the master @WillAyd could you help with the environment issue? |
||
|
||
def test_nonnumeric_exclude(self): | ||
df = DataFrame({"A": ["x", "y", "z"], "B": [1, 2, 3]}) | ||
ax = df.plot() | ||
|
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.
could we also check
color
andstyle
here?something like:
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.
see my reply below.