holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Default zoom for tile_service is too small when drawing tools are included. #197

Closed sdc50 closed 5 years ago

sdc50 commented 6 years ago

The following provides a reasonable default zoom:

gv.tile_sources.StamenTerrain()

image

However, if a drawing tool is included then the extents are zoomed in beyond reason:

tiles = gv.tile_sources.StamenTerrain()
points = gv.Points([])
point_stream = PointDraw(source=points)
tiles * points

image

sdc50 commented 6 years ago

To manually set the extents, I would have expected the following to work, but it produces an error:

tiles = gv.tile_sources.StamenTerrain(extents=(-125, 25, -65, 50))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-19-bb0038a7d3fe> in <module>()
----> 1 tiles = gv.tile_sources.StamenTerrain(extents=(-125, 25, -65, 50))
      2 points = gv.Points([])
      3 point_stream = PointDraw(source=points)
      4 tiles * points

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/holoviews/core/dimension.py in __call__(self, options, **kwargs)
   1147             self.warning('Use of __call__ to set options will be deprecated '
   1148                          'in future. Use the equivalent opts method instead.')
-> 1149         return self.opts(options, **kwargs)
   1150 
   1151     def opts(self, options=None, backend=None, clone=True, **kwargs):

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/holoviews/core/dimension.py in opts(self, options, backend, clone, **kwargs)
   1211         elif clone:
   1212             obj = self.map(lambda x: x.clone(id=x.id))
-> 1213         StoreOptions.set_options(obj, options, backend=backend, **kwargs)
   1214         return obj
   1215 

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/holoviews/core/options.py in set_options(cls, obj, options, backend, **kwargs)
   1697         # {'Image.Channel:{'plot':  Options(size=50),
   1698         #                  'style': Options('style', cmap='Blues')]}
-> 1699         options = cls.merge_options(Store.options(backend=backend).groups.keys(), options, **kwargs)
   1700         spec, compositor_applied = cls.expand_compositor_keys(options)
   1701         custom_trees, id_mapping = cls.create_custom_trees(obj, spec)

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/holoviews/core/options.py in merge_options(cls, groups, options, **kwargs)
   1565             for k, d in kwargs.items():
   1566                 if spec_key in d:
-> 1567                     kws = d[spec_key]
   1568                     additions.update({k:kws})
   1569             if spec_key not in options:

IndexError: tuple index out of range
philippjfr commented 6 years ago

This should work:

tiles = gv.tile_sources.StamenTerrain(extents=(-125, 25, -65, 50))

We also now have a global_extent plot option:

tiles = gv.tile_sources.StamenTerrain.options(global_extent=True)

However in general you are absolutely right to expect overlaying the empty element should not change the initial zoom level and this is something I hope to address as part of the work on extents and padding I'm doing in holoviews.

kcpevey commented 5 years ago

@sdc50 the work on extents and padding has been implemented. Can you retest and see if those work for you?