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

Add an example of reading in years in a convenient manner #3162

Closed
joelostblom opened this issue Aug 24, 2023 · 3 comments · Fixed by #3218
Closed

Add an example of reading in years in a convenient manner #3162

joelostblom opened this issue Aug 24, 2023 · 3 comments · Fixed by #3218

Comments

@joelostblom
Copy link
Contributor

As per @mattijn suggestion here #3140 (reply in thread). Since it is hard to discover it would be great to include it in the docs.

@ChiaLingWeng
Copy link
Contributor

ChiaLingWeng commented Oct 6, 2023

Hi, I would like to take this issue, but I'm not sure it's better to put it under Encoding Data Types or Times and Dates

@joelostblom
Copy link
Contributor Author

Thank you @ChiaLingWeng ! I think either of those places could technically work, but the data that is used in the Encoding Data Type section is more amenable to show this issue since it already has a column with years as integers. Maybe you could expand upon the example already given there and add another similar example with line charts underneath? Something like:

pop = data.population().assign(year=lambda df: df['year'].astype(str))

base = alt.Chart(pop).mark_line().encode(
    alt.Y('mean(people):Q').title('total population')
).properties(
    width=200,
    height=200
)

alt.hconcat(
    base.encode(x='year:Q').properties(title='year=quantitative'),
    base.encode(x='year:O').properties(title='year=ordinal'),
    base.encode(x='year:T').properties(title='year=temporal')
)

image

But please feel free to modify as you see fit and for what you think will make the best explanation of this feature. It would be helpful to also add a link in the "Times and Dates" section saying something like "If you want to plot four digit years stored as integers as temporal data, please see the ... section".

How does that sound to you?

@ChiaLingWeng
Copy link
Contributor

Great, you've almost solved it!
I'll try to make it as clear as possible.

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

Successfully merging a pull request may close this issue.

3 participants