Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfea06c9

Browse files
committed
ENH: Add grouped_bar() method
1 parent6083ecd commitfea06c9

File tree

8 files changed

+416
-0
lines changed

8 files changed

+416
-0
lines changed

‎doc/_embedded_plots/grouped_bar.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
importmatplotlib.pyplotasplt
2+
3+
categories= ['A','B']
4+
data0= [1.0,3.0]
5+
data1= [1.4,3.4]
6+
data2= [1.8,3.8]
7+
8+
fig,ax=plt.subplots(figsize=(4,2.2))
9+
ax.grouped_bar(
10+
[data0,data1,data2],
11+
tick_labels=categories,
12+
labels=['dataset 0','dataset 1','dataset 2'],
13+
colors=['#1f77b4','#58a1cf','#abd0e6'],
14+
)
15+
ax.legend()

‎doc/api/axes_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Basic
6767
Axes.bar
6868
Axes.barh
6969
Axes.bar_label
70+
Axes.grouped_bar
7071

7172
Axes.stem
7273
Axes.eventplot

‎doc/api/pyplot_summary.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Basic
6060
bar
6161
barh
6262
bar_label
63+
grouped_bar
6364
stem
6465
eventplot
6566
pie
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Grouped bar charts
2+
------------------
3+
4+
The new method `~.Axes.grouped_bar()` simplifies the creation of grouped bar charts
5+
significantly. It supports different input data types (lists of datasets, dicts of
6+
datasets, data in 2D arrays, pandas DataFrames), and allows for easy customization
7+
of placement via controllable distances between bars and between bar groups.
8+
9+
Example:
10+
11+
..plot::
12+
:include-source: true
13+
14+
import matplotlib.pyplot as plt
15+
16+
categories = ['A', 'B']
17+
datasets = {
18+
'dataset 0': [1.0, 3.0],
19+
'dataset 1': [1.4, 3.4],
20+
'dataset 2': [1.8, 3.8],
21+
}
22+
23+
fig, ax = plt.subplots(figsize=(4, 2.2))
24+
ax.grouped_bar(datasets, tick_labels=categories)
25+
ax.legend()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp