-
Notifications
You must be signed in to change notification settings - Fork 796
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
Faceted map example chart #1711
Comments
Try this: import altair as alt
from vega_datasets import data
states = alt.topo_feature(data.us_10m.url, 'states')
source = data.income.url
alt.Chart(source).mark_geoshape().encode(
shape=alt.Shape(field='geo', type='geojson'),
color='pct:Q',
column='group:N',
tooltip=['name:N', 'group:N', 'pct:Q']
).transform_lookup(
lookup='id',
from_=alt.LookupData(data=states, key='id'),
as_='geo'
).properties(
width=75,
height=150
).project(
type='albersUsa'
) I noticed there is no shorthand for |
Here's an example using the LA riots sample dataset import altair as alt
from vega_datasets import data
df = data.la_riots()
n = alt.topo_feature('https://gist.githubusercontent.com/irisslee/70039051188dac8f64e14182b5a459a9/raw/2412c45551cff577f7b10604ca523bd3f4dd31d3/countytopo.json', 'county')
LAbasemap = alt.Chart(n).mark_geoshape(
fill='lightgray',
stroke='white'
).properties(width = 400, height =400).project('mercator')
points = alt.Chart().mark_circle().encode(
longitude = 'longitude:Q',
latitude='latitude:Q',
size = alt.value(15),
color = 'gender:N'
)
alt.layer(LAbasemap, points, data=df).facet('gender:N') |
That's a nice example of the mechanics of a faceted map, but I think for this particular dataset the visualization would be more effective without splitting it across facets. |
What do you see as an ideal example of a faceted map for the gallery?
…On Thu, Oct 3, 2019, 8:21 PM Jake Vanderplas ***@***.***> wrote:
That's a nice example of the mechanics of a faceted map, but I think for
this particular dataset the visualization would be more effective without
splitting it across facets.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1711>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAACOCMC7QXEF63373YFC63QM2ZCZANCNFSM4I3LKKBQ>
.
|
I haven't been able to come up with a good example. |
I add one already in #1714.. |
In news graphics, the most common case for a faceted map is when you want
to create a set of "mini multiples" that compare quantitative values on a
shared scaled across a set of competing nominative values.
A current example would be mapping the location of campaign donors across
America for the 20+ Democratic presidential candidates.
If you want something in that ballpark, I think we should look for a sample
50 state dataset that has a nominative facet where the different categories
show some variety across the country.
…On Thu, Oct 3, 2019, 10:50 PM mattijn ***@***.***> wrote:
I add one already in #1714
<#1714>..
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1711>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAACOCPVUJO7WS7U26KQJGDQM3KQ7ANCNFSM4I3LKKBQ>
.
|
I think facets by time series segment or by a quantitative bracket are interesting, but I'd wager that both are much less common than charts that facet by a nominative category. |
How does a facet by quantitative data look like? Albeit years can be a quantitative data type as well, aren't they used as nominative categories here? import altair as alt
from vega_datasets import data
countries = alt.topo_feature(data.world_110m.url, 'countries')
source = 'https://raw.githubusercontent.com/mattijn/datasets/master/cities_prediction_population.csv'
base = alt.Chart(countries).mark_geoshape(
fill='lightgray',
stroke='white',
strokeWidth=0.2
).properties(width=300, height=200).project('naturalEarth1')
cities = alt.Chart().mark_circle().encode(
latitude='lat:Q',
longitude='lon:Q',
size=alt.Size('population:Q',scale=alt.Scale(range=[0, 1000]), legend=alt.Legend(title="Population (million)")),
fill=alt.value('green'),
stroke=alt.value('white'),
tooltip=['city:N','population:Q']
)
alt.layer(base, cities, data=source).facet(
facet='year:N',
columns=2,
title='The 20 Most Populous Cities in the World by 2100'
) Based on https://www.visualcapitalist.com/animated-map-worlds-populous-cities-2100/ |
Perhaps I am not using the term nominative correctly, but in this example
you give I would say you are still grouping an ordinal time series at the
end of the day.
The result is an example that is slightly more complex, and less common,
than one where the dataset already possesses a simple categorical column,
like politician candidate in my earlier example, or like gender in the one
given by Iris Lee.
…On Fri, Oct 4, 2019, 8:32 AM mattijn ***@***.***> wrote:
How does a facet by quantitative data look like? Albeit years can be a
quantitative data type as well, aren't they used as nominative categories
here?
import altair as altfrom vega_datasets import data
countries = alt.topo_feature(data.world_110m.url, 'countries')
source = 'https://raw.githubusercontent.com/mattijn/datasets/master/cities_prediction_population.csv'
base = alt.Chart(countries).mark_geoshape(
fill='lightgray',
stroke='white',
strokeWidth=0.2
).properties(width=300, height=200).project('naturalEarth1')
cities = alt.Chart().mark_circle().encode(
latitude='lat:Q',
longitude='lon:Q',
size=alt.Size('population:Q',scale=alt.Scale(range=[0, 1000]), legend=alt.Legend(title="Population (million)")),
fill=alt.value('green'),
stroke=alt.value('white'),
tooltip=['city:N','population:Q']
)
alt.layer(base, cities, data=source).facet(
facet='year:N',
columns=2,
title='The 20 Most Populous Cities in the World by 2100'
)
[image: image]
<https://user-images.githubusercontent.com/5186265/66219935-5bd65200-e6cc-11e9-9314-e858a74efd4a.png>
Based on
https://www.visualcapitalist.com/animated-map-worlds-populous-cities-2100/
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1711>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAACOCONVNIMW5ET2KYKF6LQM5OYRANCNFSM4I3LKKBQ>
.
|
Yeah, my example is more ordinal then nominal |
In my opinion, the best Altair examples import from With those requirements, I'm not sure there's a suitable dataset in the current example list other than the LA riots dataset used by @irisslee. However, that set may require the import of outside geographies for the base map, something I think we should also aim to avoid. Unless we can find a good candidate with the examples, or solve the issue of the base map for the riots data, I think we should consider nominating a new example dataset for vega_datasets to document this relatively common news chart. |
@mattijn was this not solved by? If we were going by the issue title/description alone; your example (US Income by State: Wrapped Facet) seems like the solution. Reading through the thread, it isn't clear to me what the additional requirements would be for closing the issue Note I'm trying to do some housekeeping on old issues, e.g. closing, labelling, adding relationships. |
Happy new year @dangotbanned! Maybe something like species richness for a limited number of species. Taken from here, but then preferably aggregated per county, instead of raster cells. |
@mattijn in that case, how about we source a suitable dataset and open an issue in https://github.com/vega/vega-datasets? We could then have access to it after dealing with: |
Sounds good to me! |
Great @mattijn ! I'm not 100% sure the license for the dataset you linked would work for us A potential starting point might be here though https://github.com/datasets |
Two data sources for consideration: Zillow Research Data: https://www.zillow.com/research/data/ A sample US housing dataset derived from the Zillow data. |
A demo I created a few years ago for using the Zillow housing data. I am not quite sure about the dataset license though. Demo: https://www.youtube.com/watch?v=gMghAsNuTbw If the Zillow dataset license does not work for you, https://datacommons.org/ has a lot of other open datasets. |
#1711 (comment), #1711 (comment) Thanks for showing interest in this issue @giswqs! I've just updated the description with an overview of what work I'm thinking we need to do. Hope you find that helpful. I don't personally work with spatial data, but I'm quite impressed by your GitHub profile! 🧠 |
Tasks
Based on (#1711 (comment)), (#1711 (comment))
Tip
The tasks below should be completed in order of appearance.
Earlier tasks can be performed by any contributor (new or old) familiar with
alt.Chart.mark_geoshape
Example (not
altair
)(#1711 (comment)) @mattijn
Maybe something like species richness for a limited number of species.
Similar to below, from here, but then preferably aggregated per county, instead of raster cells:
The text was updated successfully, but these errors were encountered: