-
-
Notifications
You must be signed in to change notification settings - Fork 406
Labels
Description
ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc should be added within the dropdown below.)
Software Version Info
HoloViews: 1.21.0rc0
Bokeh: 3.7.3
Pandas: 2.3.0
Numpy: 2.2.6
Description of expected behavior and the observed behavior
When plotting a categorical heatmap using hv.HeatMap
with the Matplotlib backend, the y-axis category order appears flipped, despite explicitly setting an ordered CategoricalDtype for the y-axis values.
This does not occur in the Bokeh backend.
Expected behaviour
The y-axis should display the values matching the order in the dataset:
Deep
Intermediate
Shallow
Actual Behaviour
The y-axis values are flipped.
Complete, minimal, self-contained example code that reproduces the issue
import pandas as pd
import holoviews as hv
import numpy as np
hv.extension('bokeh', 'matplotlib')
data = pd.DataFrame({
'depth_class': ['Shallow', 'Shallow', 'Shallow',
'Intermediate', 'Intermediate',
'Deep', 'Deep', 'Deep'],
'mag_class': ['Light', 'Moderate', 'Strong',
'Light', 'Moderate',
'Light', 'Moderate', 'Major'],
'count': [301, 37, 2, 212, 8, 34, 1, 1]
})
data['depth_class'] = pd.Categorical(data['depth_class'], categories=['Shallow', 'Intermediate', 'Deep'], ordered=True)
data['mag_class'] = pd.Categorical(data['mag_class'], categories=['Light', 'Moderate', 'Strong', 'Major'], ordered=True)
data
# Bokeh Plot - Correct
heatmap = hv.HeatMap(data, ['mag_class', 'depth_class'])
heatmap = heatmap.aggregate(function=np.mean)
heatmap.opts(width=400, height=300, tools=['hover'])
# Matplotlib Plot - Incorrect
hv.output(backend="matplotlib")
heatmap.opts(fig_size=120)
Stack traceback and/or browser JavaScript console output
None
Screenshots or screencasts of the bug in action
See above