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

Reimplement Path, Contours and Polygons plots #1991

Merged
merged 39 commits into from Oct 22, 2017

Conversation

Projects
None yet
3 participants
@philippjfr
Member

philippjfr commented Oct 10, 2017

Over the past few months I've slowly been laying the groundwork to support more powerful Path, Contours and Polygons elements and in this PR I am also finally exposing this new functionality in plotting classes. This PR finishes off some final issues with the internally facing API and will reimplements the plotting classes based on this new API.

New features:

  • Path, Contours and Polygons can now have any number of value dimensions associated with them which are revealed while hovering and which can be colored by.
  • Each geometry in a Contours or Polygons element can now have a different value associated with it, so you no longer have to create huge NdOverlays with one element per geometry.
  • Path now allows supplying varying value dimensions which are drawn as paths with continuously varying color.

Here is a demo of the new (and old) features.

This PR will address the following issues:

and will allow me to finish off my geopandas interface in geoviews:

@jbednar

This comment has been minimized.

Member

jbednar commented Oct 10, 2017

Fabulous! Was the county name meant to be visible in the hover?

image

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 10, 2017

Fabulous! Was the county name meant to be visible in the hover?

Yes, not quite done yet :-)

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 10, 2017

Actually nevermind, it does work, I just hadn't declared County as a dimension.

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 20, 2017

Additional user API is not part of this PR btw, the two main things I think we should still add are:

  • Allow groupby by value dimensions on Contours/Polygon (but not Path)
  • Allow selecting subpaths by index and value dimensions
@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 20, 2017

It looks like you've found a few more things to improve in this PR. I'll review it once you think it is ready again...

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 20, 2017

It looks like you've found a few more things to improve in this PR. I'll review it once you think it is ready again...

It's ready, I just hadn't pushed stuff I'd done before.

"green05 = levels.Overlay.Green[0.5]\n",
"green05 + green05.Channel + green05.Channel.Green.sample(y=0.0)"
"green05 = levels.Contours.Green\n",
"green05 + chans.Channel.Green + chans.Channel.Green.sample(y=0.0)"

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

Doesn't this have implications for backwards compatibility?

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Guess it has some, it's no longer overlaid by default. I could have made it be overlaid again but I generally don't want to.

" for name, xs, ys, rate in zip(county_names, county_xs, county_ys, county_rates)}\n",
"\n",
"choropleth = hv.NdOverlay(county_polys, kdims=['County'])"
"choropleth = hv.Polygons(counties, ['lons', 'lats'], [('detailed name', 'County'), 'Unemployment'])"

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

I assume the old code still works and the new approach is just more succinct/flexible/efficient.

This comment has been minimized.

@philippjfr
"Polygons with values can be used to build heatmaps with arbitrary shapes."
"In order to efficiently represent the scalar values associated with each path the dictionary format is preferable since it can store the scalar values without expanding them into a whole column. Additionally it allows passing multiple columns as a single array by specifying the dimension names as a tuple.\n",
"\n",
"In this example we will createa list of random polygons each with an associated ``level`` value. Polygons will default to using the first value dimension as the ``color_index`` but for clarity we will define the ``color_index`` explicitly:"

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

createa -> create a

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Thanks.

@@ -155,7 +155,7 @@
"source": [
"%%opts Contours (linewidth=1.3) Image (cmap=\"gray\")\n",
"cs = contours(penguins[:,:,'R'], levels=[0.10,0.80])\n",
"cs"
"penguins[:, :, 'R'] * cs"

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

The operation no longer just adds contours on top of the input and return it? That's fine as long as there is a switch to restore the old behavior. I also suspect we may have made this change a while back.

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

I see you changed the default - see comment below.

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

We would at least need to document this change of behavior in the changelog/release notes.

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Right, may start requiring committers adding backwards compatibility changes to the CHANGELOG when they are made so we don't forget about them. Will do that here.

gridded = False
# Denotes whether the interface expects multiple ragged arrays

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

Does it have to be arrays? Isn't it ragged 'data' (i.e multiple elements of different lengths)?

This comment has been minimized.

@philippjfr
@@ -415,22 +415,17 @@ class contours(Operation):
filled = param.Boolean(default=False, doc="""
Whether to generate filled contours""")
overlaid = param.Boolean(default=True, doc="""
overlaid = param.Boolean(default=False, doc="""

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

Ok, this answers my earlier question.

color_index = param.ClassSelector(default=None, class_=(util.basestring, int),
allow_None=True, doc="""
Index of the dimension from which the color will the drawn""")

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

Would be nice to get the op proposal in soon...

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Agreed.

contour = Contours([[(-0.5, 0.416667, 0.5), (-0.25, 0.5, 0.5)],
[(0.25, 0.5, 0.5), (0.5, 0.45, 0.5)]],
vdims=img.vdims)
print(contour.range(2))

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

Stray print.

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Thanks I'll delete it.

@@ -20,7 +20,9 @@ class MultiInterface(Interface):
datatype = 'multitabular'
subtypes = ['dataframe', 'dictionary', 'array', 'dask']
subtypes = ['dictionary', 'dataframe', 'array', 'dask']

This comment has been minimized.

@jlstevens

jlstevens Oct 21, 2017

Member

I think it makes sense to try the more general dictionary (i.e standard python literals) format first. Might be other implications I haven't figured out yet. Then again, MultiInterface is pretty new so it probably doesn't matter wrt backwards compatibility.

This comment has been minimized.

@philippjfr

philippjfr Oct 22, 2017

Member

Right, the point here is that it doesn't accidentally expand your scalar values into a dataframe column for instance.

This comment has been minimized.

@jlstevens

jlstevens Oct 22, 2017

Member

Makes sense.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 21, 2017

Looks good. My main comments are:

  • I am assuming old code still works and that many of the updates to the notebooks just show the new, cleaner way of doing things.
  • We need to be clear about any changes to behavior, e.g the way the contour function no longer overlays thing.
  • The change in how you use attribute access in the introduction notebook seems like the most worrying change I noticed...
  • Reading notebook diffs is tricky - I can't tell if you only updated the element notebooks or added material to showcase all the new functionality. Github's notebook rendering seems off (a problem with the HTML maybe?):

image

If you haven't added material it would be good to see more examples (e.g of the split method).

Anyway, none of this is critical and once a few of my comments above are addressed (typos, stray print and other minor things), I'm happy to merge. The main other thing I would like is more examples for the docs.

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 22, 2017

I am assuming old code still works and that many of the updates to the notebooks just show the new, cleaner way of doing things.

Correct.

We need to be clear about any changes to behavior, e.g the way the contour function no longer overlays thing.

Yes, contours needs a note about backward compatibility.

The change in how you use attribute access in the introduction notebook seems like the most worrying change I noticed...

This is a result of two things 1) it's no longer overlaid by default and b) contours now returns a single Contours element not an NdOverlay of them so this falls under "noting contours backward compatibility changes".

Reading notebook diffs is tricky - I can't tell if you only updated the element notebooks or added material to showcase all the new functionality. Github's notebook rendering seems off (a problem with the HTML maybe?):

Not sure what you're referring to, looks fine to me. Anyway, I completely overhauled the element reference notebooks adding more material.

If you haven't added material it would be good to see more examples (e.g of the split method).

I'm working on a "Working with Geometries" user guide which will cover stuff like this. Will see how far I get with that, but I can add it in a later PR.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 22, 2017

Ok great!

Should contours get a compatibility flag in config? If we find ourselves with a number of small backwards incompatibility issues, we could group them under a new config flag.

That doesn't need to be decided right away and I'll merge once you get rid of that stray print and fix that typo.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 22, 2017

The tests have now passed except for on transient error (build restarted and still running).

Merging.

@jlstevens jlstevens merged commit 73038d7 into master Oct 22, 2017

3 of 4 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 79.798%
Details
s3-reference-data-cache Test data is cached.
Details

@philippjfr philippjfr deleted the new_path_plots branch Oct 28, 2017

@philippjfr philippjfr added this to the v1.9 milestone Nov 2, 2017

@pyup-bot pyup-bot referenced this pull request Nov 3, 2017

Closed

Update holoviews to 1.9.0 #104

@pyup-bot pyup-bot referenced this pull request Nov 13, 2017

Closed

Update holoviews to 1.9.1 #120

@pyup-bot pyup-bot referenced this pull request Dec 12, 2017

Merged

Update holoviews to 1.9.2 #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment