Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scatter_matrix formatting considered harmful #1285

Open
jbednar opened this issue Feb 21, 2024 · 9 comments
Open

scatter_matrix formatting considered harmful #1285

jbednar opened this issue Feb 21, 2024 · 9 comments
Labels
type: bug Something isn't working type: discussion type: upstream Anything that requires work outside hvPlot

Comments

@jbednar
Copy link
Member

jbednar commented Feb 21, 2024

ALL software version info

Python : 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ]
Operating system : macOS-14.0-arm64-arm-64bit
Panel comms : default

holoviews : 1.18.3
bokeh : 3.3.4
colorcet : 3.0.1
dask : 2023.6.0
datashader : 0.16.0
geoviews : 1.11.0
hvplot : 0.9.2
IPython : 8.15.0
jupyterlab : 4.0.11
matplotlib : 3.8.0
notebook : 7.0.6
numba : 0.58.0
numpy : 1.24.3
pandas : 2.1.1
panel : 1.3.1
param : 2.0.1
pillow : 10.0.1
pyarrow : 11.0.0
pyviz_comms : 2.3.0
scipy : 1.11.3
spatialpandas : 0.4.9
xarray : 2023.6.0

Description of expected behavior and the observed behavior

I'd expect scatter_matrix to be formatted reasonably: subplots all lined up, axis labels readable, text not overlapping, and a single Bokeh toolbar for the entire figure. That's not what's happening:

import pandas as pd
import hvplot.pandas
from hvplot import scatter_matrix

url = 'https://raw.githubusercontent.com/shoukewei/data/main/data-pydm/gdp_top_six_economies.csv'
df = pd.read_csv(url)
scatter_matrix(df, alpha=0.5, width=600, height=600, xrotation=0)
image
scatter_matrix(df, alpha=0.5, width=600, height=600, xrotation=90)
image
@jbednar jbednar added the TRIAGE label Feb 21, 2024
@droumis
Copy link
Member

droumis commented Feb 21, 2024

Just adding that the spacing issue seems unrelated to the toolbar:

scatter_matrix(df, alpha=0.5, width=600, height=600, xrotation=0).opts(toolbar='above')

image

@jbednar
Copy link
Member Author

jbednar commented Feb 21, 2024

Just adding that the spacing issue seems unrelated to the toolbar:

Yes, I think the spacing issues have been there for some time, while the toolbar issue is relatively recent, but I haven't tried to do a git bisect to pin that down.

@maximlt
Copy link
Member

maximlt commented Feb 22, 2024

Quick feedback:

https://holoviews.org/reference/containers/bokeh/GridSpace.html
image

There may be no hvPlot issue at all.

@maximlt maximlt added type: bug Something isn't working type: upstream Anything that requires work outside hvPlot and removed TRIAGE labels Feb 22, 2024
@jbednar
Copy link
Member Author

jbednar commented Feb 22, 2024

Thanks. I've opened holoviz/holoviews#6126 for the toolbar issue, and @mattpap is looking at it from the Bokeh side.

@mattpap
Copy link

mattpap commented Feb 22, 2024

Bad plot alignment is caused by fixed frame sizing (Plot.frame_{width,height,align}), which works reliably only for single plots and doesn't work well in all other cases (see e.g. issue bokeh/bokeh#13225). I suppose it's time to implement this properly.

@maximlt
Copy link
Member

maximlt commented Mar 6, 2024

From the initial list of issues:

  1. subplots all lined up: Mateusz indicated this is a Bokeh issue
  2. a single Bokeh toolbar for the entire figure: HoloViews issue fixed in Don't show figures toolbar on GridSpace holoviews#6127
  3. axis labels readable, text not overlapping

That leaves us with 3). The default Bokeh formatter is the BasicTickFormatter:

image image

Comparing that to the default of plotly express:
image

We can get a similar behavior defining a NumericalTickFormatter:
image

However, it also has its limits:
image

Certainly, we could better document xformatter/yformatter. But should we also consider defaulting to a more user-friendly formatter?

@jbednar
Copy link
Member Author

jbednar commented Mar 6, 2024

Defaulting to a more usable formatter sounds like a great idea. @mattpap , any idea why the tick formatter didn't decide to drop the intermediate tick marks? Here I'd be hoping to get one label on the left of the x axis, and one on the right:

image

@mattpap
Copy link

mattpap commented Mar 6, 2024

any idea why the tick formatter didn't decide to drop the intermediate tick marks?

This is handled setting Axis.major_label_policy = NoOverlap(). When this was implemented the default (AllLabels) was left for backwards compatibility. Tickers and tick formatters have no access to the screen space, so they can't make any adjustments based on the positioning of labels.

@jbednar
Copy link
Member Author

jbednar commented Mar 6, 2024

Thanks! Ok, @maxime, can you try out the NoOverlap option with NumericalTickFormatter? For hvPlot I strongly favor improving the user experience over preserving previous defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working type: discussion type: upstream Anything that requires work outside hvPlot
Projects
None yet
Development

No branches or pull requests

4 participants