Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cticks #1368

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ class HoloViewsConverter:
'colormap',
'fontsize',
'c',
'cticks',
'cmap',
'color_key',
'cnorm',
Expand Down Expand Up @@ -552,6 +553,7 @@ def __init__(
invert=False,
stacked=False,
colorbar=None,
cticks=None,
ahuang11 marked this conversation as resolved.
Show resolved Hide resolved
datashade=False,
rasterize=False,
downsample=None,
Expand Down Expand Up @@ -790,6 +792,12 @@ def __init__(
plot_opts['colorbar'] = True
elif self.rasterize:
plot_opts['colorbar'] = plot_opts.get('colorbar', True)
if plot_opts.get('colorbar') is True and cticks is not None:
if self._backend == 'plotly':
raise ValueError('cticks option is not supported for plotly backend')
key = 'cticks' if self._backend == 'bokeh' else 'cbar_ticks'
self._style_opts[key] = cticks

if 'logz' in kwds and 'logz' in self._kind_options.get(self.kind, {}):
plot_opts['logz'] = kwds.pop('logz')
if invert:
Expand Down
8 changes: 8 additions & 0 deletions hvplot/tests/testoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,11 @@ def test_dataset_scatter_with_title(self, ds2, backend):
plot = ds_sel.hvplot.scatter(x='foo', y='bar') # Image plot
opts = Store.lookup_options(backend, plot, 'plot')
assert opts.kwargs['title'] == 'time = 0, y = 0, x = 0, band = 0'


@pytest.mark.usefixtures('load_xarray_accessor')
class TestXarrayCticks:
def test_cticks(self, da2):
plot = da2.isel(other=0).hvplot(cticks=[5, 10])
handles = hv.renderer('bokeh').get_plot(plot).handles
assert handles['colorbar'].ticker.ticks == [5, 10]
Loading