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

docs: Fix "Layered chart with Dual-Axis" (Method syntax) #3660

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Oct 27, 2024

Discovered while writing tests for #3659.

The User Guide displays the attribute syntax, but the method syntax one was not equivalent.

Results in no titleColor being applied and is silently ignored during validation.

Previous

Note: the warning from pylance is only showing due to some local changes I have on-top of (1a39019)

Code block

import altair as alt
from vega_datasets import data

source = data.seattle_weather()

base = alt.Chart(source).encode(alt.X("month(date):T").title(None))

area = base.mark_area(opacity=0.3, color="#57A44C").encode(
    alt.Y("average(temp_max)").title("Avg. Temperature (°C)", titleColor="#57A44C"),
    alt.Y2("average(temp_min)"),
)

line = base.mark_line(stroke="#5276A7", interpolate="monotone").encode(
    alt.Y("average(precipitation)").title(
        "Precipitation (inches)", titleColor="#5276A7"
    )
)

alt.layer(area, line).resolve_scale(y="independent")

image

Fixed

Code block

import altair as alt
from vega_datasets import data

source = data.seattle_weather()

base = alt.Chart(source).encode(alt.X("month(date):T").title(None))
area = base.mark_area(opacity=0.3, color="#57A44C").encode(
    alt.Y("average(temp_max)").axis(
        title="Avg. Temperature (°C)", titleColor="#57A44C"
    ),
    alt.Y2("average(temp_min)"),
)

line = base.mark_line(stroke="#5276A7", interpolate="monotone").encode(
    alt.Y("average(precipitation)").axis(
        title="Precipitation (inches)", titleColor="#5276A7"
    )
)

alt.layer(area, line).resolve_scale(y="independent")

image

Discovered while writing tests for #3659.
The attribute syntax version is what is displayed, but the method syntax one was not equivalent.

Results in no `titleColor` being applied and is silently ignored during validation.

https://altair-viz.github.io/gallery/layered_chart_with_dual_axis.html
@dangotbanned dangotbanned enabled auto-merge (squash) October 27, 2024 12:59
@dangotbanned dangotbanned merged commit 6beec7b into main Oct 27, 2024
22 checks passed
@dangotbanned dangotbanned deleted the fix-layered-chart-with-dual-axis-methods branch October 27, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.title() does not support all the argument in axis(title=...) but still lists them in the docstring
1 participant