hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

first tick label on categorical x-axis misplaced when labels are rotated

Open JanHomann opened this issue 3 years ago • 6 comments
trafficstars

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

Screen Shot 2022-10-09 at 1 21 28 AM

JanHomann avatar Oct 09 '22 05:10 JanHomann

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?

jbednar avatar Oct 10 '22 21:10 jbednar

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.

mattpap avatar Oct 10 '22 22:10 mattpap

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.

JanHomann avatar Oct 10 '22 23:10 JanHomann

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.

jbednar avatar Oct 11 '22 18:10 jbednar

No, it's a secondary issue that was fixed (no more "invalid bbox" messages). The misplaced tick label is still a problem.

mattpap avatar Oct 11 '22 20:10 mattpap

Ah, the ever-ambiguous "this" was fixed. :-/

jbednar avatar Oct 11 '22 21:10 jbednar