Skip to content

Commit

Permalink
Merge pull request #537 from eitanlees/non-local-url-fix
Browse files Browse the repository at this point in the history
Nonlocal URL Fix
  • Loading branch information
jakevdp authored Feb 28, 2018
2 parents 73eed85 + 398cb0c commit ea9cfd2
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 60 deletions.
2 changes: 1 addition & 1 deletion altair/vegalite/v2/examples/aggregate_bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import altair as alt
from vega_datasets import data

source = data.population()
source = data.population.url

chart = alt.Chart(source).mark_bar().encode(
x = alt.X('sum(people):Q', axis = alt.Axis(title = 'population')),
Expand Down
4 changes: 2 additions & 2 deletions altair/vegalite/v2/examples/binned_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
source = data.movies()

chart = alt.Chart(source).mark_circle().encode(
x = alt.X('IMDB_Rating', bin = alt.BinParams(maxbins=10)),
y = alt.Y('Rotten_Tomatoes_Rating', bin = alt.BinParams(maxbins=10)),
x = alt.X('IMDB_Rating:Q', bin = alt.BinParams(maxbins=10)),
y = alt.Y('Rotten_Tomatoes_Rating:Q', bin = alt.BinParams(maxbins=10)),
size = 'count(*):Q'
)
15 changes: 8 additions & 7 deletions altair/vegalite/v2/examples/boxplot_max_min.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
https://vega.github.io/vega-lite/examples/box-plot_minmax_2D_vertical_normalized.html
"""
import altair as alt
from vega_datasets import data

population = alt.load_dataset('population')
population = data.population.url

# Define aggregate fields
lower_box = 'q1(people)'
lower_whisker = 'min(people)'
upper_box = 'q3(people)'
upper_whisker = 'max(people)'
lower_box = 'q1(people):Q'
lower_whisker = 'min(people):Q'
upper_box = 'q3(people):Q'
upper_whisker = 'max(people):Q'

# Compose each layer individually
lower_plot = alt.Chart(population).mark_rule().encode(
Expand All @@ -37,11 +38,11 @@
)

middle_tick = alt.Chart(population).mark_tick(color='white', size=5.0).encode(
y='median(people)',
y='median(people):Q',
x='age:O',
)

chart = alt.layer(lower_plot,
middle_plot,
upper_plot,
middle_tick)
middle_tick)
3 changes: 1 addition & 2 deletions altair/vegalite/v2/examples/diverging_stacked_bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import altair as alt
from vega_datasets import data

data = [
{
Expand Down Expand Up @@ -363,4 +362,4 @@
y = alt.Y('question:N', axis = y_axis),
color = alt.Color('type:N',
legend=alt.Legend( title='Response'),
scale = color_scale,))
scale = color_scale,))
2 changes: 0 additions & 2 deletions altair/vegalite/v2/examples/gantt_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import altair as alt
from vega_datasets import data

data = [
{"task": "A","start": 1, "end": 3},
Expand All @@ -15,7 +14,6 @@

source = alt.pd.DataFrame(data)


chart = alt.Chart(source).mark_bar().encode(
x = 'start',
x2 = 'end',
Expand Down
8 changes: 4 additions & 4 deletions altair/vegalite/v2/examples/gapminder_bubble_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import altair as alt
from vega_datasets import data

gapminder = data.gapminder_health_income()
gapminder = data.gapminder_health_income.url

chart = alt.Chart(gapminder).mark_circle().encode(
x = alt.X('income', scale = alt.Scale(type = 'log')),
y = alt.Y('health', scale = alt.Scale(zero=False)),
size = 'population'
x = alt.X('income:Q', scale = alt.Scale(type = 'log')),
y = alt.Y('health:Q', scale = alt.Scale(zero=False)),
size = 'population:Q'
)
2 changes: 1 addition & 1 deletion altair/vegalite/v2/examples/grouped_bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import altair as alt
from vega_datasets import data

source = data.population()
source = data.population.url

chart = alt.Chart(source).mark_bar(stroke = 'transparent').encode(
x = alt.X('gender:N', scale = alt.Scale(rangeStep = 12), axis = alt.Axis(title = '')),
Expand Down
5 changes: 3 additions & 2 deletions altair/vegalite/v2/examples/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
https://vega.github.io/vega-lite/examples/histogram.html
"""
import altair as alt
from vega_datasets import data

movies = alt.load_dataset('movies')
movies = data.movies.url

chart = alt.Chart(movies).mark_bar().encode(
x=alt.X("IMDB_Rating",
Expand All @@ -15,4 +16,4 @@
maxbins=10,
)),
y='count(*):Q',
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import altair as alt
from vega_datasets import data

source = data.movies()
source = data.movies.url

bar = alt.Chart(source).mark_bar().encode(
x = alt.X('IMDB_Rating:Q', bin = True, axis = None),
Expand Down
2 changes: 1 addition & 1 deletion altair/vegalite/v2/examples/layered_bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import altair as alt
from vega_datasets import data

source = data.population()
source = data.population.url

chart = alt.Chart(source).mark_bar(opacity = 0.7).encode(
x = alt.X('age:O', scale = alt.Scale(rangeStep = 17)),
Expand Down
18 changes: 7 additions & 11 deletions altair/vegalite/v2/examples/line_percent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
import altair as alt
from vega_datasets import data

source = data.jobs()

# The year here is stored by pandas as an integer. When treating columns as dates,
# it is best to use either a string representation or a datetime representation.
source.year = source.year.astype(str)

welders = source[source.job == 'Welder']
source = data.jobs.url

chart = alt.Chart(welders).mark_line().encode(
x=alt.X('year', timeUnit='year'),
y=alt.Y('perc', axis=alt.Axis(format='%')),
color='sex'
chart = alt.Chart(source).mark_line().encode(
x=alt.X('year:O'),
y=alt.Y('perc:Q', axis=alt.Axis(format='%')),
color='sex:N'
).properties(
title='Percent of work-force working as Welders'
)

chart.transform = [{"filter": {"field": "job", "equal": "Welder"}}]
4 changes: 2 additions & 2 deletions altair/vegalite/v2/examples/natural_disasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import altair as alt
from vega_datasets import data

source = data.disasters()
source = data.disasters.url

chart = alt.Chart(source).mark_circle(opacity = 0.8, stroke = 'black', strokeWidth = 1).encode(
x = alt.X('Year:O', axis = alt.Axis(labelAngle = 0)),
y = alt.X('Entity:N'),
size = alt.Size('Deaths:Q', scale = alt.Scale(range = [0, 5000]),
legend = alt.Legend(title = 'Annual Global Deaths')),
color = alt.Color('Entity', legend = None)
color = alt.Color('Entity:N', legend = None)
).properties(width=600, height=400)

chart.transform = [{"filter": "datum.Entity !== 'All natural disasters'"}]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import altair as alt
from vega_datasets import data

source = data.population()
source = data.population.url

chart = alt.Chart(source).mark_bar().encode(
x = alt.X('age:O', scale = alt.Scale(rangeStep = 17)),
Expand Down
14 changes: 7 additions & 7 deletions altair/vegalite/v2/examples/ranged_dot_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import altair as alt
from vega_datasets import data

source = data.countries()
source = data.countries.url


line = alt.Chart().mark_line(color='#db646f').encode(
x = 'life_expect',
y = 'country',
detail = 'country'
x = 'life_expect:Q',
y = 'country:N',
detail = 'country:N'
).interactive()

point = alt.Chart().mark_point(size = 100, opacity = 1, filled = True).encode(
x = 'life_expect',
y = 'country',
x = 'life_expect:Q',
y = 'country:N',
color=alt.Color('year:O',
scale=alt.Scale(
domain=['1955', '2000'],
Expand All @@ -29,4 +29,4 @@

chart = alt.layer(line + point, data = source,
transform = [{'filter': {"field": 'country', "oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]}},
{'filter': {"field": 'year', "oneOf": [1955, 2000]}}])
{'filter': {"field": 'year', "oneOf": [1955, 2000]}}])
8 changes: 4 additions & 4 deletions altair/vegalite/v2/examples/streamgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import altair as alt
from vega_datasets import data

source = data.unemployment_across_industries()
source = data.unemployment_across_industries.url


chart = alt.Chart(source).mark_area().encode(
x = alt.X('date:T', timeUnit = 'yearmonth',
axis=alt.Axis(format='%Y', domain = False, tickSize = 0)),
y = alt.Y('sum(count)', stack = 'center', axis = None),
color = alt.Color('series', scale=alt.Scale(scheme='category20b'))
).interactive()
y = alt.Y('sum(count):Q', stack = 'center', axis = None),
color = alt.Color('series:N', scale=alt.Scale(scheme='category20b'))
).interactive()
10 changes: 5 additions & 5 deletions altair/vegalite/v2/examples/table_binned_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import altair as alt
from vega_datasets import data

source = data.movies()
source = data.movies.url

chart = alt.Chart(source).mark_rect().encode(
x = alt.X('IMDB_Rating', bin = alt.BinParams(maxbins=60)),
y = alt.Y('Rotten_Tomatoes_Rating', bin = alt.BinParams(maxbins=40)),
color = alt.Color('count(IMDB_Rating)',
x = alt.X('IMDB_Rating:Q', bin = alt.BinParams(maxbins=60)),
y = alt.Y('Rotten_Tomatoes_Rating:Q', bin = alt.BinParams(maxbins=40)),
color = alt.Color('count(IMDB_Rating):Q',
scale=alt.Scale(scheme='greenblue'))
)
)
4 changes: 2 additions & 2 deletions altair/vegalite/v2/examples/table_bubble_plot_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import altair as alt
from vega_datasets import data

source = data.github()
source = data.github.url

chart = alt.Chart(source).mark_circle().encode(
x = alt.X('time:O', timeUnit = 'hours'),
y = alt.X('time:O', timeUnit = 'day'),
size = 'sum(count)')
size = 'sum(count):Q')
10 changes: 5 additions & 5 deletions altair/vegalite/v2/examples/trellis_scatter_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import altair as alt
from vega_datasets import data

source = data.movies()
source = data.movies.url

chart = alt.Chart(source).mark_point().encode(
x = 'Worldwide_Gross',
y = 'US_DVD_Sales',
column = 'MPAA_Rating'
)
x = 'Worldwide_Gross:Q',
y = 'US_DVD_Sales:Q',
column = 'MPAA_Rating:N'
)

0 comments on commit ea9cfd2

Please sign in to comment.