Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/_embedded_plots/grouped_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import matplotlib.pyplot as plt

categories = ['A', 'B']
data0 = [1.0, 3.0]
data1 = [1.4, 3.4]
data2 = [1.8, 3.8]

fig, ax = plt.subplots(figsize=(4, 2.2))
ax.grouped_bar(
[data0, data1, data2],
tick_labels=categories,
labels=['dataset 0', 'dataset 1', 'dataset 2'],
colors=['#1f77b4', '#58a1cf', '#abd0e6'],
)
ax.legend()
1 change: 1 addition & 0 deletions doc/api/axes_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Basic
Axes.bar
Axes.barh
Axes.bar_label
Axes.grouped_bar

Axes.stem
Axes.eventplot
Expand Down
1 change: 1 addition & 0 deletions doc/api/bezier_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.. automodule:: matplotlib.bezier
:members:
:undoc-members:
:special-members: __call__
:show-inheritance:
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/30070-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``BezierSegment.point_at_t``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is deprecated. Instead, it is possible to call the BezierSegment with an argument.
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/30088-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*fontfile* parameter of ``PdfFile.createType1Descriptor``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This parameter is deprecated; all relevant pieces of information are now
directly extracted from the *t1font* argument.
10 changes: 10 additions & 0 deletions doc/api/next_api_changes/removals/30004-DS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
``apply_theta_transforms`` option in ``PolarTransform``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Applying theta transforms in `~matplotlib.projections.polar.PolarTransform` and
`~matplotlib.projections.polar.InvertedPolarTransform` has been removed, and
the ``apply_theta_transforms`` keyword argument removed from both classes.

If you need to retain the behaviour where theta values
are transformed, chain the ``PolarTransform`` with a `~matplotlib.transforms.Affine2D`
transform that performs the theta shift and/or sign shift.
4 changes: 0 additions & 4 deletions doc/api/next_api_changes/removals/xxxxxx-DS.rst

This file was deleted.

1 change: 1 addition & 0 deletions doc/api/pyplot_summary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Basic
bar
barh
bar_label
grouped_bar
stem
eventplot
pie
Expand Down
26 changes: 26 additions & 0 deletions doc/users/next_whats_new/grouped_bar.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Grouped bar charts
------------------

The new method `~.Axes.grouped_bar()` simplifies the creation of grouped bar charts
significantly. It supports different input data types (lists of datasets, dicts of
datasets, data in 2D arrays, pandas DataFrames), and allows for easy customization
of placement via controllable distances between bars and between bar groups.

Example:

.. plot::
:include-source: true
:alt: Diagram of a grouped bar chart of 3 datasets with 2 categories.

import matplotlib.pyplot as plt

categories = ['A', 'B']
datasets = {
'dataset 0': [1, 11],
'dataset 1': [3, 13],
'dataset 2': [5, 15],
}

fig, ax = plt.subplots()
ax.grouped_bar(datasets, tick_labels=categories)
ax.legend()
2 changes: 1 addition & 1 deletion galleries/examples/axisartist/demo_axis_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setup_axes(fig, rect):
grid_helper = GridHelperCurveLinear(
(
Affine2D().scale(np.pi/180., 1.) +
PolarAxes.PolarTransform(apply_theta_transforms=False)
PolarAxes.PolarTransform()
),
extreme_finder=angle_helper.ExtremeFinderCycle(
20, 20,
Expand Down
3 changes: 1 addition & 2 deletions galleries/examples/axisartist/demo_curvelinear_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def curvelinear_test2(fig):

# PolarAxes.PolarTransform takes radian. However, we want our coordinate
# system in degree
tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform(
apply_theta_transforms=False)
tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform()
# Polar projection, which involves cycle, and also has limits in
# its coordinates, needs a special method to find the extremes
# (min, max of the coordinate within the view).
Expand Down
5 changes: 2 additions & 3 deletions galleries/examples/axisartist/demo_floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def setup_axes2(fig, rect):
With custom locator and formatter.
Note that the extreme values are swapped.
"""
tr = PolarAxes.PolarTransform(apply_theta_transforms=False)
tr = PolarAxes.PolarTransform()

pi = np.pi
angle_ticks = [(0, r"$0$"),
Expand Down Expand Up @@ -99,8 +99,7 @@ def setup_axes3(fig, rect):
# scale degree to radians
tr_scale = Affine2D().scale(np.pi/180., 1.)

tr = tr_rotate + tr_scale + PolarAxes.PolarTransform(
apply_theta_transforms=False)
tr = tr_rotate + tr_scale + PolarAxes.PolarTransform()

grid_locator1 = angle_helper.LocatorHMS(4)
tick_formatter1 = angle_helper.FormatterHMS()
Expand Down
3 changes: 1 addition & 2 deletions galleries/examples/axisartist/demo_floating_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
def curvelinear_test2(fig):
"""Polar projection, but in a rectangular box."""
# see demo_curvelinear_grid.py for details
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform(
apply_theta_transforms=False)
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()

extreme_finder = angle_helper.ExtremeFinderCycle(20,
20,
Expand Down
3 changes: 1 addition & 2 deletions galleries/examples/axisartist/simple_axis_pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def setup_axes(fig, rect):
"""Polar projection, but in a rectangular box."""

# see demo_curvelinear_grid.py for details
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform(
apply_theta_transforms=False)
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()

extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
lon_cycle=360,
Expand Down
16 changes: 4 additions & 12 deletions galleries/examples/lines_bars_and_markers/barchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# data from https://allisonhorst.github.io/palmerpenguins/

import matplotlib.pyplot as plt
import numpy as np

species = ("Adelie", "Chinstrap", "Gentoo")
penguin_means = {
Expand All @@ -19,22 +18,15 @@
'Flipper Length': (189.95, 195.82, 217.19),
}

x = np.arange(len(species)) # the label locations
width = 0.25 # the width of the bars
multiplier = 0

fig, ax = plt.subplots(layout='constrained')

for attribute, measurement in penguin_means.items():
offset = width * multiplier
rects = ax.bar(x + offset, measurement, width, label=attribute)
ax.bar_label(rects, padding=3)
multiplier += 1
res = ax.grouped_bar(penguin_means, tick_labels=species, group_spacing=1)
for container in res.bar_containers:
ax.bar_label(container, padding=3)

# Add some text for labels, title and custom x-axis tick labels, etc.
# Add some text for labels, title, etc.
ax.set_ylabel('Length (mm)')
ax.set_title('Penguin attributes by species')
ax.set_xticks(x + width, species)
ax.legend(loc='upper left', ncols=3)
ax.set_ylim(0, 250)

Expand Down
Loading