Skip to content

How to conveniently plots 4 character integers as years (temporal data) #3140

Answered by mattijn
joelostblom asked this question in Q&A
Discussion options

You must be logged in to vote

Use str as dtype for the year column in your dataframe works as well:

import altair as alt
from vega_datasets import data

source = data.wheat()
source.year = source.year.astype(str)

alt.Chart(source).mark_point().encode(
    x='year:T',
    y='wheat',
)

Not sure how you could know this upfront.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@joelostblom
Comment options

@mattijn
Comment options

Answer selected by joelostblom
@mattijn
Comment options

@joelostblom
Comment options

@joelostblom
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants