Description
Bug summary
When using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular barh
, float values do not work in the second argument position to specify heights.
You can hack it by using other categorical values (see example below), but this only works for integral heights and is generally yucky.
Code for reproduction
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.broken_barh([(0, 5-0), (10, 13-10)], ('car engine', 1))
ax.broken_barh([(3, 6-3), ], ('jackhammer', 1))
ax.broken_barh([(1, 4-1), ], ('children playing', 1))
Above does not work. Substituting a categorical value (which maps to 1) does work:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
# 'jackhammer' is implicitly height=1 in this example
ax.broken_barh([(0, 5-0), (10, 13-10)], ('car engine', 'jackhammer'))
ax.broken_barh([(3, 6-3), ], ('jackhammer', 'jackhammer'))
ax.broken_barh([(1, 4-1), ], ('children playing', 'jackhammer'))
Actual outcome
ConversionError: Failed to convert value(s) to axis units: ('car engine', 1)
Expected outcome
It should be possible to specify heights by numerical values as well as / instead of categorical positions.
Additional information
For broader context, the full description of my use case is at https://discourse.matplotlib.org/t/advice-for-using-broken-bar-collections-with-categorical-axes/23171?u=brian.mcfee
Best guess for fix: set this up however it was done over in barh 🤷
Probably this also affects broken_bar (vertical) as well.
Operating system
No response
Matplotlib Version
3.6.3
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
conda