hvplot
hvplot copied to clipboard
first tick label on categorical x-axis misplaced when labels are rotated
Versions
hvplot 0.8.1
holoviews 1.15.1
pandas 1.5.0
python 3.9.13
jupyterlab 3.4.5
Chrome Browser
Description
The first tick label on a categorical x-axis is not correctly placed horizontally when tick labels are rotated at an angle (not 0 or 90 degrees). It is much closer to the second tick label than it should be. I noticed that while working with a larger set of labels. This can also be easily seen with a smaller set of labels by making the plot very narrow. I have tested bar, area, line, and scatter. They all have that issue.
Example
import hvplot.pandas
import pandas as pd
df = pd.DataFrame([["Steven Spielberg", 5],
["Alfred Hitchcock", 4],
["Stanley Kubrick", 4],
["Billy Wilder", 4],
["John Huston", 3]],
columns=['Director', 'Frequency'])
df.hvplot.bar(rot=45, x='Director', y='Frequency', width=150)
Stack traceback
No error message.
Screenshots
Thanks. My guess is that this is a Bokeh issue rather than HoloViews, since I don't think HoloViews messes with the spacing of individual labels. Making a pure-Bokeh example might be difficult for hvplot users, but maybe this is enough for you to go on, @mattpap?
Looks similar to this https://github.com/bokeh/bokeh/issues/12069 one, which is easily reproducible in bokeh. I didn't have chance yet to investigate why this happens.
Looks similar to this bokeh/bokeh#12069 one, which is easily reproducible in bokeh. I didn't have chance yet to investigate why this happens.
@mattpap I think that the plotting library sees the vertical y-axis label as the outer left edge of the plot, so any tick label that extends beyond that gets shifted inwards. But I could be wrong.
The Bokeh issue suggests it's fixed in bokeh 3.0, which is imminent, though it may be some time before holoviz tools support the big changes that 3.0 brings.
No, it's a secondary issue that was fixed (no more "invalid bbox" messages). The misplaced tick label is still a problem.
Ah, the ever-ambiguous "this" was fixed. :-/