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

formatting: scale_x_datetime should apply date-time formatting to the breaks #392

Closed
alshan opened this issue Jun 11, 2021 · 1 comment
Closed
Assignees

Comments

@alshan
Copy link
Collaborator

alshan commented Jun 11, 2021

t = pd.to_datetime("2021-01-01")
(ggplot() 
  + geom_vline(xintercept=t)
  + scale_x_datetime(format="%d %b\'%y"))

works as expected:
image

Scale with 'breaks' doesn't work:

(ggplot() 
  + geom_vline(xintercept=ut)
  + scale_x_datetime(format="%d %b\'%y", breaks=[t]))

image

(ggplot() 
  + geom_vline(xintercept=ut)
  + scale_x_datetime(format="{%d %b\'%y}", breaks=[t]))

Wrong number pattern: %d %b'%y

(ggplot() 
  + geom_vline(xintercept=t)
  + scale_x_datetime(breaks=[t]))

image

After converting pandas Timestamp to "UNIX time" It doesn't work either:

# UNIX time (delta from UNIX epoch in ms)
ut = (pd.to_datetime("2021-01-01") - pd.Timestamp("1970-01-01")) // pd.Timedelta("1ms")

(ggplot() 
  + geom_vline(xintercept=ut)
  + scale_x_datetime(breaks=[ut]))

image

@OLarionova-HORIS
Copy link
Collaborator

Applying date-time formatting to breaks works now:
#421 - date-time format support was added to StringFormat.

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

No branches or pull requests

2 participants