@@ -119,10 +119,9 @@ def test_bar_colors(self):
119
119
tm .close ()
120
120
121
121
custom_colors = "rgcby"
122
- for kw in ["c" , "color" ]:
123
- ax = df .plot .bar (** {kw : "rgcby" })
124
- self ._check_colors (ax .patches [::5 ], facecolors = custom_colors )
125
- tm .close ()
122
+ ax = df .plot .bar (color = "rgcby" )
123
+ self ._check_colors (ax .patches [::5 ], facecolors = custom_colors )
124
+ tm .close ()
126
125
127
126
from matplotlib import cm
128
127
@@ -138,17 +137,15 @@ def test_bar_colors(self):
138
137
self ._check_colors (ax .patches [::5 ], facecolors = rgba_colors )
139
138
tm .close ()
140
139
141
- for kw in ["c" , "color" ]:
142
- ax = df .loc [:, [0 ]].plot .bar (** {kw : "DodgerBlue" })
143
- self ._check_colors ([ax .patches [0 ]], facecolors = ["DodgerBlue" ])
144
- tm .close ()
140
+ ax = df .loc [:, [0 ]].plot .bar (color = "DodgerBlue" )
141
+ self ._check_colors ([ax .patches [0 ]], facecolors = ["DodgerBlue" ])
142
+ tm .close ()
145
143
146
144
ax = df .plot (kind = "bar" , color = "green" )
147
145
self ._check_colors (ax .patches [::5 ], facecolors = ["green" ] * 5 )
148
146
tm .close ()
149
147
150
- @pytest .mark .parametrize ("kw" , ["c" , "color" ])
151
- def test_bar_user_colors (self , kw ):
148
+ def test_bar_user_colors (self ):
152
149
df = DataFrame (
153
150
{"A" : range (4 ), "B" : range (1 , 5 ), "color" : ["red" , "blue" , "blue" , "red" ]}
154
151
)
@@ -160,7 +157,7 @@ def test_bar_user_colors(self, kw):
160
157
(0.0 , 0.0 , 1.0 , 1.0 ),
161
158
(1.0 , 0.0 , 0.0 , 1.0 ),
162
159
]
163
- ax = df .plot .bar (y = "A" , ** { kw : df ["color" ]} )
160
+ ax = df .plot .bar (y = "A" , color = df ["color" ])
164
161
result = [p .get_facecolor () for p in ax .patches ]
165
162
assert result == expected
166
163
@@ -216,17 +213,15 @@ def test_if_scatterplot_colorbars_are_next_to_parent_axes(self):
216
213
assert np .isclose (parent_distance , colorbar_distance , atol = 1e-7 ).all ()
217
214
218
215
@pytest .mark .parametrize ("cmap" , [None , "Greys" ])
219
- def test_scatter_with_c_column_name_with_colors (self , cmap ):
216
+ @pytest .mark .parametrize ("kw" , ["c" , "color" ])
217
+ def test_scatter_with_c_column_name_with_colors (self , cmap , kw ):
220
218
# https://github.com/pandas-dev/pandas/issues/34316
221
219
df = DataFrame (
222
220
[[5.1 , 3.5 ], [4.9 , 3.0 ], [7.0 , 3.2 ], [6.4 , 3.2 ], [5.9 , 3.0 ]],
223
221
columns = ["length" , "width" ],
224
222
)
225
223
df ["species" ] = ["r" , "r" , "g" , "g" , "b" ]
226
- ax = df .plot .scatter (x = 0 , y = 1 , c = "species" , cmap = cmap )
227
- assert ax .collections [0 ].colorbar is None
228
-
229
- ax = df .plot .scatter (x = 0 , y = 1 , color = "species" , cmap = cmap )
224
+ ax = df .plot .scatter (x = 0 , y = 1 , cmap = cmap , ** {kw : "species" })
230
225
assert ax .collections [0 ].colorbar is None
231
226
232
227
def test_scatter_colors (self ):
0 commit comments