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

[FEATURE] datetime formatting: enhance default formatting #13186

Open
muendlein opened this issue Jun 7, 2023 · 3 comments · May be fixed by #13854
Open

[FEATURE] datetime formatting: enhance default formatting #13186

muendlein opened this issue Jun 7, 2023 · 3 comments · May be fixed by #13854

Comments

@muendlein
Copy link
Contributor

muendlein commented Jun 7, 2023

Problem description

Note: This probably needs some discussion.

Currently the default formatting provides ticks with mixed formats (see screenshots below). In my opinion this makes it extremely difficult to read the axis and to be honest I don't see any benefit over just having the same formatting for all ticks.
The first screenshot is probably an extreme example with three different formats but it highlights pretty well what the problem is.

bokeh_formatter_dt_3
bokeh_formatter_dt_2

Code for reference:

import pandas as pd
from bokeh.io import curdoc
from bokeh.models import DatetimeTickFormatter
from bokeh.plotting import figure

import numpy as np

t = pd.date_range("2023-06-01", periods=11).tz_localize("US/Pacific") #.tz_localize(None)
print(t)
y = np.linspace(0, 10, 11)

fig = figure(x_axis_type="datetime")
fig.line(t, y)

doc = curdoc()
doc.add_root(fig)

Feature description

Improve default formatting by avoiding mixed formats. Perhaps it might also be possible to adapt a Matlab style formatting which provides an additional label for the whole axis.

bokeh_formatter_dt_4

Potential alternatives

keep it as it is

Additional information

No response

@bryevdv
Copy link
Member

bryevdv commented Jun 7, 2023

@muendlein Bokeh already supports multiple levels of datetime tick format context:

https://docs.bokeh.org/en/latest/docs/user_guide/styling/plots.html#datetime-tick-context

Are you proposing that this existing feature be used by default? I'm not sure there is anything that will satisfy everyone here, which makes me slightly inclined to preserve the status quo and simply make customization features as accessible and known a possible.

@muendlein
Copy link
Contributor Author

muendlein commented Jun 8, 2023

@bryevdv Thank you for pointing out that multiple levels are already available!
Of course I am fully aware of that not everyone can be satisfied but I think the default settings should be designed to satisfy most which I don't really see right now. In particular when there are established implementations that do it differently (better).

My proposal is two-fold:

  • Utilize the secondary level to provide more information. I think this should be a no-brainer because it just simply provides additional information. Currently when zoomed in and you will see only hours and minutes without any date context which is not helpful. Note: It's also worth pointing out that this is pretty common in order libraries/languages (i.e. plotly, Matlab).
  • Do not used mixed formats for tick labels on the same level, i.e.
    mixed_formats
    This is an absolute nightmare in terms of readability and I cannot see why anyone would really want that.

Both of my points are essentially covered by the plotly library (example: https://plotly.com/python/time-series/#time-series-with-range-slider).
Example screenshots of different zoom levels from the plotly example:

image
image
image
image

@bryevdv
Copy link
Member

bryevdv commented Jul 6, 2023

@muendlein Did you want to submit a PR for consideration? Speaking plainly I think this will move much faster, even it if requires some iteration and back and forth, if someone champions a concrete proposal to start from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants