Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if rot:
axis = 'yrotation' if invert else 'xrotation'
plot_opts[axis] = rot
tools = list(tools) or list(plot_opts.get('tools', []))
if hover is None:
hover = not self.datashade
if hover and not any(t for t in tools if isinstance(t, HoverTool)
or t == 'hover'):
tools.append('hover')
plot_opts['tools'] = tools
if self.crs and global_extent:
plot_opts['global_extent'] = global_extent
if projection:
plot_opts['projection'] = process_crs(projection)
if title is not None:
plot_opts['title_format'] = title
if (self.kind in self._colorbar_types or self.rasterize or self.datashade or self._color_dim):
try:
if not use_dask:
symmetric = self._process_symmetric(symmetric, clim, check_symmetric_max)
if self._style_opts.get('cmap') is None:
if symmetric:
self._style_opts['cmap'] = self._default_cmaps['diverging']
else:
self._style_opts['cmap'] = self._default_cmaps['linear']
if symmetric is not None:
plot_opts['symmetric'] = symmetric
except TypeError:
def _process_crs(self, data, crs):
"""Given crs as proj4 string, data.attr, or cartopy.crs return cartopy.crs
"""
# get the proj string: either the value of data.attrs[crs] or crs itself
_crs = getattr(data, 'attrs', {}).get(crs or 'crs', crs)
try:
return process_crs(_crs)
except ValueError:
# only raise error if crs was specified in kwargs
if crs:
raise ValueError(
"'{}' must be either a valid crs or an reference to "
"a `data.attr` containing a valid crs.".format(crs))
pos = nx.drawing.spring_layout
if not isinstance(pos, dict):
pos = pos(G, **kwargs.get('layout_kwargs', {}))
params, label_params = {}, {}
label_element = Labels
if kwargs.get('geo', False) or 'crs' in kwargs:
try:
import geoviews
except ImportError:
raise ImportError('In order to use geo-related features '
'the geoviews library must be available. '
'It can be installed with:\n conda '
'install -c pyviz geoviews')
crs = process_crs(kwargs.get('crs'))
label_element = geoviews.Labels
params['cls'] = geoviews.Graph
params['crs'] = crs
label_params['crs'] = crs
# Construct Graph object
g = _from_networkx(G, pos, **params)
if 'nodelist' in kwargs:
g.nodes.data = g.nodes.data.iloc[list(kwargs['nodelist'])]
if 'edgelist' in kwargs:
edges = g.array([0, 1])
comparisons = []
for edge in kwargs['edgelist']:
comparisons.append(edges == edge)