| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + import matplotlib.pyplot as plt | ||
| 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() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,6 +67,7 @@ Basic | |||
| 67 | 67 | Axes.bar | |
| 68 | 68 | Axes.barh | |
| 69 | 69 | Axes.bar_label | |
| 70 | + Axes.grouped_bar | ||
| 70 | 71 | ||
| 71 | 72 | Axes.stem | |
| 72 | 73 | Axes.eventplot | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,6 +60,7 @@ Basic | |||
| 60 | 60 | bar | |
| 61 | 61 | barh | |
| 62 | 62 | bar_label | |
| 63 | + grouped_bar | ||
| 63 | 64 | stem | |
| 64 | 65 | eventplot | |
| 65 | 66 | pie | |
| Original file line number | Diff line number | Diff 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() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments