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

Date axis disappearing when plots are composed #3845

Closed
jg10545 opened this issue Jul 24, 2019 · 1 comment · Fixed by #4179
Closed

Date axis disappearing when plots are composed #3845

jg10545 opened this issue Jul 24, 2019 · 1 comment · Fixed by #4179
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working
Milestone

Comments

@jg10545
Copy link

jg10545 commented Jul 24, 2019

I've been trying to reproduce something like your lovely measles example, with data aggregated to the day rather than the year. The behavior of the date axis seems really counterintuitive; is this intended?

hv.__version__ 1.12.3

import numpy as np
import pandas as pd
import datetime as dt

import holoviews as hv
hv.extension("bokeh")

# generate fake event data
N = 1000
df = pd.DataFrame({
    "date":[dt.datetime(2019,1,1,0)+dt.timedelta(hours=x) for x in
           np.random.uniform(0, 1000, size=N)],
    "foo":np.random.choice(["foo", "bar", "foobar", "barfoo"], size=N)
})
df["date"] = df.date.dt.date

# aggregate to counts per foo per day
df = df.groupby(["date", "foo"]).size().reset_index()
df.columns = ["date", "foo", "count"]

# build a heatmap
heatmap = hv.HeatMap(df).opts(width=500, height=200, xaxis=None)

# also aggregate results across foo for a line plot
agg = hv.Dataset(heatmap).aggregate("date", np.sum)
line = hv.Curve(agg).opts(width=500, height=150)

The hv.Curve plot automagically builds a date axis:
image

If I compose the heatmap and the curve, the x-axes are linked but the axis labels are screwed up:
image

If I compose them with the order reversed, the date axis comes back but the plots become unlinked:
image

Seems spooky. Is this intended or am I doing something horribly wrong?

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Oct 3, 2019
@philippjfr
Copy link
Member

The problem here is that it's trying to link the axes despite the fact that one is a datetime axis and the other a categorical axis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: backend: bokeh type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants