Altair: rename axes?

Created on 11 Jun 2018  路  6Comments  路  Source: altair-viz/altair

Does altair have redim-like or xlab/ylab-like functionality?

I know it's possible to set axis titles via alt.Axis(title='NEW TITLE'), but I'm wondering if it's possible to do this in an alternate way, say if the chart object has already been created, but one just wants to modify the axis labels. For example in ggplot:

p <- ggplot(df) +
    geom_point(aes(x, y))
p

# "curious plot, i wonder what it looks like with axis titles"
p +
    xlab("interesting axis 1") +
    ylab("interesting axis 2")
question

Most helpful comment

You could do something like this:

chart = alt.Chart(data).encode(
    alt.X('foo'),
    alt.Y('bar')
)

chart.encoding.x.title = 'new title'
chart.encoding.y.title = 'another new title'

All 6 comments

You could do something like this:

chart = alt.Chart(data).encode(
    alt.X('foo'),
    alt.Y('bar')
)

chart.encoding.x.title = 'new title'
chart.encoding.y.title = 'another new title'

I don't anticipate us adding new top-level functions to adjust parts of the plot.

Is it possible to change the titles for each sub-chart in repeatChart (e.g. by feeding a list)?

How do you do this for the main chart as oppose to just the axes?

I figured it out.
bar_graph = bar_graph.properties(title='your title')

Is it possible to pass font family arguments to properties for the title?

Yes, for example:

chart = alt.Chart(data).encode(
    alt.X('foo', title='Foo', axis=alt.Axis(titleFont="Helvetica Neue"))
)

more axis properties can be seen at https://altair-viz.github.io/user_guide/generated/core/altair.Axis.html

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fischcheng picture fischcheng  路  4Comments

floringogianu picture floringogianu  路  3Comments

bmcfee picture bmcfee  路  3Comments

dzonimn picture dzonimn  路  3Comments

morberg picture morberg  路  3Comments