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)
| 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 = '' |