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

Add the plot legend to the GeoJSON properties #35

Open
ocefpaf opened this issue Jan 13, 2016 · 3 comments
Open

Add the plot legend to the GeoJSON properties #35

ocefpaf opened this issue Jan 13, 2016 · 3 comments

Comments

@ocefpaf
Copy link
Collaborator

ocefpaf commented Jan 13, 2016

I guess that mplleaflet follow the simplestyle-spec closely and what I propose here this is not in the simplestyle-spec, but it would be nice to use the legend information to create popups later on. (Or just to keep track of who-is-who in the JSON.)

@jwass is that something you would be OK to add? If so I can take try to implementing this.

@jwass
Copy link
Owner

jwass commented Jan 15, 2016

@ocefpaf Can you provide an example? I've always wanted legends to show up on the final page.

One of the goals of mplleaflet is to allow plotting in matplotlib normally and it just "does the right thing" to generate the web page. Is there a way to create a legend using plt.legend and then just inspect that to create a legend on the resulting page?

@ocefpaf
Copy link
Collaborator Author

ocefpaf commented Jan 15, 2016

I've always wanted legends to show up on the final page.

Yeah, maybe that is better and more consistent with mplleaflet's goal. (But not exactly what I had in mind 😉)
l

Is there a way to create a legend using plt.legend and then just inspect that to create a legend on the resulting page?

Probably yes. Just not sure how to do it yet. What I was thinking was to just export GeoJSON with the label string information as a popup property for each geometry.

For example: in cell [5] of this notebook I add the drifter label to each line. The easiest way to propagate the drifter name to the map would be the save the label string in the "properties" field and then use it as a popup for each line.

BTW adding the actually legend in the final page could be done via two routes:

a) (the ugly hack) save the legend as a PNG images and add it using L.control

b) (the elegant solution) Create a custom legend control with the proper css, symbols, colors, and text. All exported from the original legend.

Right now I am selfishly thinking about just creating a mpl2geojson that has the functionality I need. As I learn more about leaflet I will try to get back to this issue and add export the legend.

@jwass
Copy link
Owner

jwass commented Jan 15, 2016

Ah. I see. So use the matplotlib legend to set properties on the exported features? That would be really nice.

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

No branches or pull requests

2 participants