MCPcopy Create free account
hub / github.com/holoviz/hvplot / _plot

Method _plot

hvplot/ui.py:654–723  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

652 setattr(self, pname, p.objects[0])
653
654 def _plot(self):
655 y = self.y_multi if 'y_multi' in self._controls.parameters else self.y
656 if isinstance(y, list) and len(y) == 1:
657 y = y[0]
658 kwargs = {}
659 for v in self.param.values().values():
660 # Geo is not enabled so not adding it to kwargs
661 if isinstance(v, Geographic) and not v.geo:
662 continue
663
664 if isinstance(v, Advanced):
665 opts_kwargs = v.kwargs.get('opts', {})
666 elif isinstance(v, Controls):
667 kwargs.update(v.kwargs)
668
669 if kwargs.get('geo'):
670 if 'crs' not in kwargs:
671 xmax = np.max(np.abs(self.xlim()))
672 self.geographic.crs = 'PlateCarree' if xmax <= 360 else 'GOOGLE_MERCATOR'
673 kwargs['crs'] = self.geographic.crs
674 for key in ['crs', 'projection']:
675 if key not in kwargs:
676 continue
677 crs_kwargs = kwargs.pop(f'{key}_kwargs', {})
678 kwargs[key] = instantiate_crs_str(kwargs.pop(key), **crs_kwargs)
679 feature_scale = kwargs.pop('feature_scale', None)
680 kwargs['features'] = {feature: feature_scale for feature in kwargs.pop('features', [])}
681
682 kwargs['min_height'] = 400
683 df = self._data
684 show_alert = False
685 if len(df) > MAX_ROWS and not (
686 self.kind in KINDS['stats'] or kwargs.get('rasterize') or kwargs.get('datashade')
687 ):
688 warn_message = (
689 f'plotted {MAX_ROWS} rows out of {len(df)} rows '
690 f'to avoid performance issues; use rasterize=True or datashade=True to visualize more.'
691 )
692 if self.kind == 'line':
693 warn_message = f'Selected the first {MAX_ROWS} rows and {warn_message}'
694 df = df.head(MAX_ROWS)
695 else:
696 warn_message = f'Randomly sampled and {warn_message}'
697 df = df.sample(n=MAX_ROWS)
698 self._alert.param.update(object=warn_message, visible=True)
699 param.main.param.warning(warn_message)
700 show_alert = True
701 self._data = df
702 self._layout.loading = True
703 try:
704 self._hvplot = _hvPlot(self._data)(
705 kind=self.kind, x=self.x, y=y, by=self.by, groupby=self.groupby, **kwargs
706 )
707 if opts_kwargs:
708 self._hvplot.opts(**opts_kwargs)
709 self._hv_pane.object = self._hvplot
710 # Working around a Panel issue that cause the widgets not to
711 # be well aligned when in a Row layout.

Callers 1

_refreshMethod · 0.95

Calls 2

instantiate_crs_strFunction · 0.85
xlimMethod · 0.45

Tested by

no test coverage detected