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

Update URLs and field names to match the new vega weather datasets #2310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions altair/examples/weather_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from vega_datasets import data

# Since the data is more than 5,000 rows we'll import it from a URL
source = data.seattle_temps.url
source = data.seattle_weather_hourly_normals.url

alt.Chart(
source,
title="2010 Daily High Temperature (F) in Seattle, WA"
).mark_rect().encode(
x='date(date):O',
y='month(date):O',
color=alt.Color('max(temp):Q', scale=alt.Scale(scheme="inferno")),
color=alt.Color('max(temperature):Q', scale=alt.Scale(scheme="inferno")),
tooltip=[
alt.Tooltip('monthdate(date):T', title='Date'),
alt.Tooltip('max(temp):Q', title='Max Temp')
alt.Tooltip('max(temperature):Q', title='Max Temp')
]
).properties(width=550)
12 changes: 6 additions & 6 deletions doc/user_guide/times_and_dates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ containing hourly temperatures measured in Seattle:
import altair as alt
from vega_datasets import data

temps = data.seattle_temps()
temps = data.seattle_weather_hourly_normals.url
temps.head()

We can see from the ``dtypes`` attribute that the times are encoded as a standard
Expand All @@ -109,7 +109,7 @@ example, we'll limit ourselves to the first two weeks of data:

alt.Chart(temps).mark_line().encode(
x='date:T',
y='temp:Q'
y='temperature:Q'
)

(notice that for date/time values we use the ``T`` to indicate a temporal
Expand All @@ -128,7 +128,7 @@ x-axis, and day of the month on the y-axis:
alt.Chart(temps).mark_rect().encode(
alt.X('hoursminutes(date):O', title='hour of day'),
alt.Y('monthdate(date):O', title='date'),
alt.Color('temp:Q', title='temperature (F)')
alt.Color('temperature:Q', title='temperature (F)')
)

Unless you are using a non-ES6 browser (See :ref:`note-browser-compliance`),
Expand Down Expand Up @@ -167,7 +167,7 @@ render **according to the timezone of the browser rendering it**:
alt.Chart(temps).mark_rect().encode(
alt.X('hoursminutes(date_pacific):O', title='hour of day'),
alt.Y('monthdate(date_pacific):O', title='date'),
alt.Color('temp:Q', title='temperature (F)')
alt.Color('temperature:Q', title='temperature (F)')
)

If you are viewing this chart on a computer whose time is set to the west coast
Expand Down Expand Up @@ -195,7 +195,7 @@ regardless of the system location:
alt.Chart(temps).mark_rect().encode(
alt.X('utchoursminutes(date_pacific):O', title='UTC hour of day'),
alt.Y('utcmonthdate(date_pacific):O', title='UTC date'),
alt.Color('temp:Q', title='temperature (F)')
alt.Color('temperature:Q', title='temperature (F)')
)

To make your charts as portable as possible (even in non-ES6 browsers which parse
Expand All @@ -210,7 +210,7 @@ in UTC time, both on the Pandas side and on the Vega-Lite side:
alt.Chart(temps).mark_rect().encode(
alt.X('utchoursminutes(date_utc):O', title='hour of day'),
alt.Y('utcmonthdate(date_utc):O', title='date'),
alt.Color('temp:Q', title='temperature (F)')
alt.Color('temperature:Q', title='temperature (F)')
)

This is somewhat less convenient than the default behavior for timezone-agnostic
Expand Down
12 changes: 6 additions & 6 deletions doc/user_guide/transform/timeunit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ measurements in Seattle during the year 2010:
import altair as alt
from vega_datasets import data

temps = data.seattle_temps.url
temps = data.seattle_weather_hourly_normals.url

alt.Chart(temps).mark_line().encode(
x='date:T',
y='temp:Q'
y='temperature:Q'
)

The plot is too busy due to the amount of data points squeezed into the short
Expand All @@ -51,7 +51,7 @@ and plotting only the mean monthly temperature:

alt.Chart(temps).mark_line().encode(
x='month(date):T',
y='mean(temp):Q'
y='mean(temperature):Q'
)

Notice that by default timeUnit output is a continuous quantity; if you would
Expand All @@ -63,7 +63,7 @@ This can be useful when plotting a bar chart or other discrete chart type:

alt.Chart(temps).mark_bar().encode(
x='month(date):O',
y='mean(temp):Q'
y='mean(temperature):Q'
)

Multiple time units can be combined within a single plot to yield interesting
Expand All @@ -75,7 +75,7 @@ to give a profile of Seattle temperatures through the year:
alt.Chart(temps).mark_rect().encode(
alt.X('date(date):O', title='day'),
alt.Y('month(date):O', title='month'),
color='max(temp):Q'
color='max(temperature):Q'
).properties(
title="2010 Daily High Temperatures in Seattle (F)"
)
Expand All @@ -91,7 +91,7 @@ method. For example:

alt.Chart(temps).mark_line().encode(
alt.X('month:T', axis=alt.Axis(format='%b')),
y='mean(temp):Q'
y='mean(temperature):Q'
).transform_timeunit(
month='month(date)'
)
Expand Down