Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0afe74

Browse files
committed
Apply suggestions from code review
1 parent d9aa5f6 commit e0afe74

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,9 +3057,9 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
30573057
30583058
.. code-block:: python
30593059
3060-
grouped_bar([dataset_1, dataset_2, dataset_3],
3060+
grouped_bar([dataset_0, dataset_1, dataset_2],
30613061
tick_labels=['A', 'B'],
3062-
labels=['dataset 1', 'dataset 2', 'dataset 3'])
3062+
labels=['dataset 0', 'dataset 1', 'dataset 2'])
30633063
30643064
.. plot:: _embedded_plots/grouped_bar.py
30653065
@@ -3156,13 +3156,13 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
31563156
These will show up in the legend.
31573157
31583158
group_spacing : float, default: 1.5
3159-
The space between two bar groups as multiples of bar width.
3159+
The space between two bar groups as a multiple of bar width.
31603160
31613161
The default value of 1.5 thus means that there's a gap of
31623162
1.5 bar widths between bar groups.
31633163
31643164
bar_spacing : float, default: 0
3165-
The space between bars as multiples of bar width.
3165+
The space between bars as a multiple of bar width.
31663166
31673167
orientation : {"vertical", "horizontal"}, default: "vertical"
31683168
The direction of the bars.
@@ -3181,17 +3181,17 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
31813181
31823182
Returns
31833183
-------
3184-
_GroupedBarReturn
3184+
_GroupedBarReturn
31853185
3186-
A provisional result object. This will be refined in the future.
3187-
For now, the guaranteed API on the returned object is limited to
3186+
A provisional result object. This will be refined in the future.
3187+
For now, the guaranteed API on the returned object is limited to
31883188
3189-
- the attribute ``bar_containers``, which is a list of
3190-
`.BarContainer`, i.e. the results of the individual `~.Axes.bar`
3191-
calls for each dataset.
3189+
- the attribute ``bar_containers``, which is a list of
3190+
`.BarContainer`, i.e. the results of the individual `~.Axes.bar`
3191+
calls for each dataset.
31923192
3193-
- a ``remove()`` method, that remove all bars from the Axes.
3194-
See also `.Artist.remove()`.
3193+
- a ``remove()`` method, that remove all bars from the Axes.
3194+
See also `.Artist.remove()`.
31953195
31963196
See Also
31973197
--------
@@ -3261,8 +3261,7 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
32613261
heights = heights.to_numpy().T
32623262
elif hasattr(heights, 'keys'): # dict
32633263
if labels is not None:
3264-
raise ValueError(
3265-
"'labels' cannot be used if 'heights' are a mapping")
3264+
raise ValueError("'labels' cannot be used if 'heights' is a mapping")
32663265
labels = heights.keys()
32673266
heights = list(heights.values())
32683267
elif hasattr(heights, 'shape'): # numpy array
@@ -3317,8 +3316,7 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
33173316
# place the bars, but only use numerical positions, categorical tick labels
33183317
# are handled separately below
33193318
bar_containers = []
3320-
for i, (hs, label, color) in enumerate(
3321-
zip(heights, labels, colors)):
3319+
for i, (hs, label, color) in enumerate(zip(heights, labels, colors)):
33223320
lefts = (group_centers - 0.5 * group_distance + margin_abs
33233321
+ i * (bar_width + bar_spacing_abs))
33243322
if orientation == "vertical":

lib/matplotlib/axes/_axes.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import pandas as pd
4141

4242

4343
class _GroupedBarReturn:
44+
bar_containers: list[BarContainer]
4445
def __init__(self, bar_containers: list[BarContainer]) -> None: ...
4546
def remove(self) -> None: ...
4647

@@ -273,13 +274,13 @@ class Axes(_AxesBase):
273274
) -> PolyCollection: ...
274275
def grouped_bar(
275276
self,
276-
heights : Sequence[ArrayLike] | dict[str, ArrayLike] | np.ndarray | pd.DataFrame,
277+
heights: Sequence[ArrayLike] | dict[str, ArrayLike] | np.ndarray | pd.DataFrame,
277278
*,
278-
positions : ArrayLike | None = ...,
279-
tick_labels : Sequence[str] | None = ...,
280-
labels : Sequence[str] | None = ...,
281-
group_spacing : float | None = ...,
282-
bar_spacing : float | None = ...,
279+
positions: ArrayLike | None = ...,
280+
tick_labels: Sequence[str] | None = ...,
281+
labels: Sequence[str] | None = ...,
282+
group_spacing: float | None = ...,
283+
bar_spacing: float | None = ...,
283284
orientation: Literal["vertical", "horizontal"] = ...,
284285
colors: Iterable[ColorType] | None = ...,
285286
**kwargs

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ def test_grouped_bar():
21822182
ax.set_yticks([])
21832183

21842184

2185-
@check_figures_equal(extensions=["png"])
2185+
@check_figures_equal()
21862186
def test_grouped_bar_list_of_datasets(fig_test, fig_ref):
21872187
categories = ['A', 'B']
21882188
data1 = [1, 1.2]
@@ -2205,7 +2205,7 @@ def test_grouped_bar_list_of_datasets(fig_test, fig_ref):
22052205
ax.legend()
22062206

22072207

2208-
@check_figures_equal(extensions=["png"])
2208+
@check_figures_equal()
22092209
def test_grouped_bar_dict_of_datasets(fig_test, fig_ref):
22102210
categories = ['A', 'B']
22112211
data_dict = dict(data1=[1, 1.2], data2=[2, 2.4], data3=[3, 3.6])
@@ -2219,7 +2219,7 @@ def test_grouped_bar_dict_of_datasets(fig_test, fig_ref):
22192219
ax.legend()
22202220

22212221

2222-
@check_figures_equal(extensions=["png"])
2222+
@check_figures_equal()
22232223
def test_grouped_bar_array(fig_test, fig_ref):
22242224
categories = ['A', 'B']
22252225
array = np.array([[1, 2, 3], [1.2, 2.4, 3.6]])
@@ -2235,7 +2235,7 @@ def test_grouped_bar_array(fig_test, fig_ref):
22352235
ax.legend()
22362236

22372237

2238-
@check_figures_equal(extensions=["png"])
2238+
@check_figures_equal()
22392239
def test_grouped_bar_dataframe(fig_test, fig_ref, pd):
22402240
categories = ['A', 'B']
22412241
labels = ['data1', 'data2', 'data3']

0 commit comments

Comments
 (0)