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

added example from vega-lite: one dot per zipcode #516

Merged
merged 5 commits into from
Feb 27, 2018

Conversation

afonit
Copy link
Contributor

@afonit afonit commented Feb 26, 2018

Note,
I had to have the row in here:
zipcodes = zipcodes[5000:10000]

to limit the amount of data or I get the error:
MaxRowsError: The number of rows in your dataset is greater than the max of 5000

and searching in the repo I don't see a way to temporarily lift that restriction.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

You could get around that by passing the data url rather than the dataframe, I think: replace zipcodes = data.zipcodes() with zipcodes = data.zipcodes.url

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

Also, I think it looks a bit better with size=5 instead of size=1, but I'm fine with you making that call if you feel otherwise.

@eitanlees
Copy link
Contributor

Also I think the plot is more impressive if you leave off the background states and only plot the points.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

Also I think the plot is more impressive if you leave off the background states and only plot the points.

Yeah, that does look pretty cool!
vega 8

@afonit
Copy link
Contributor Author

afonit commented Feb 27, 2018

@jakevdp I went ahead and put the .url after the data as you suggested and it works, but why?
I went to:
https://github.com/vega/vega-datasets/search?utf8=%E2%9C%93&q=url&type=
and searched on url, it only brought up two items as you can see in the search result - neither of which are methods. If you get a sec could you explain for educational sake where that .url method is coming from.

@afonit
Copy link
Contributor Author

afonit commented Feb 27, 2018

Is there a way to make this layered plot interactive,
I tired combinations of putting .interactive() on either background, points and both, nothing renders in those cases.

per the comments on this merge request.
@afonit
Copy link
Contributor Author

afonit commented Feb 27, 2018

@eitanlees , thanks for catching that,
I was looking at two examples and had missed that the background was not on this example.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

The maximum lines issue is because if you make a chart with a dataframe, it actually embeds the data within the plot spec, which is then included in the notebook. (you can see this by calling chart.to_dict() on any chart made with a dataframe). When the dataset is too large, this can get very big very quickly, and doesn't perform well in the browser.

By contrast, if you specify the data by url, the dataset itself is not embedded in the spec, only the URL reference to the dataset: the dataset is then downloaded at render time, which is much more efficient in terms of displaying plots in the notebook.

This large dataframe thing presents some real usability issues (it's easy to accidentally make gigantic notebooks, particularly when building multiple plots). There are potential solutions down the line—vega-lite has the concept of datastores with named datasets that we may be able to take advantage of—but for now we've found that raising an error if the dataset is too big is the best way to keep users from accidentally shooting themselves in the foot.

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

I've not seen any examples of interactive lat/lon plots. @kanitw, @domoritz, is it possible to have interactive scales here?

@domoritz
Copy link
Member

Not yet: vega/vega-lite#3306

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

Looks good. It would be simpler to put the projection properties directly on the point chart, and then you can remove the background layer.

per Jake's comment

states = alt.UrlData(data.us_10m.url,
format=alt.TopoDataFormat(type='topojson',
feature='states'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

states data is not used anymore

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 27, 2018

Thanks!

@jakevdp jakevdp merged commit 6dcf03a into vega:master Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants