MCPcopy Index your code
hub / github.com/holoviz/hvplot / plot_code

Method plot_code

hvplot/ui.py:797–829  ·  view source on GitHub ↗

Return a string representation that can be easily copy-pasted in a notebook cell to create a plot from a call to the `.hvplot` accessor, and that includes all the customized settings of the explorer. .. code-block:: >>> hvexplorer.plot_code(var_name='data')

(self, var_name=None)

Source from the content-addressed store, hash-verified

795 return self._hvplot.clone()
796
797 def plot_code(self, var_name=None):
798 """Return a string representation that can be easily copy-pasted
799 in a notebook cell to create a plot from a call to the `.hvplot`
800 accessor, and that includes all the customized settings of the explorer.
801
802 .. code-block::
803
804 >>> hvexplorer.plot_code(var_name='data')
805 "data.hvplot(x='time', y='value')"
806
807 Parameters
808 ----------
809 var_name: string
810 Data variable name by which the returned string will start.
811
812 Returns
813 -------
814 str
815 Code snippet
816 """
817 settings = self.settings()
818 if 'legend' not in settings:
819 settings['legend'] = 'bottom_right'
820 settings['widget_location'] = 'bottom'
821 settings_args = ''
822 if settings:
823 settings_args = self._build_kwargs_string(settings)
824 snippet = f'{var_name or self._var_name}.hvplot(\n{settings_args}\n)'
825 opts = self.advanced.opts
826 if opts:
827 opts_args = self._build_kwargs_string(opts)
828 snippet += f'.opts(\n{opts_args}\n)'
829 return snippet
830
831 def _build_kwargs_string(self, kwargs):
832 args = ''

Callers 2

_refreshMethod · 0.95
test_explorer_plot_codeFunction · 0.80

Calls 2

settingsMethod · 0.95
_build_kwargs_stringMethod · 0.95

Tested by 1

test_explorer_plot_codeFunction · 0.64