0

I would like to change the xticks and xiticklables in hv.Barplot. However, currently I could only achieve that by adding hv.Curve(bar).options(xticks = xtic_labels). This will be plotted as curve not bar plot.

Can anyone give suggestion that how I could define custom xticklables for barplot?

HEIGHT   = 300
xtick_       = np.arange(100,370,50)
xtick_labels = [(float(mz), str(mz)) for mz in xtick_]

hv.Curve(tof_pr.hvplot.bar(x='mz', y='factor_1',)).\
            options(xticks=xtick_labels)

pr_curve = tof_pr.hvplot.bar(x='mz', y='factor_1')

# I had to add this sentence
pr_curve  = hv.Curve(pr_curve).options(
             xticks = xtick_labels, width =800)

# show
pr_curve
Han Zhengzu
  • 3,694
  • 7
  • 44
  • 94
  • I found a comment on issue [#975](https://github.com/holoviz/hvplot/issues/975#issuecomment-1337176852) which mentiones that `holoviz` struggels with xticks on categorical axes. But bars are working with strings, see [the docs](https://hvplot.holoviz.org/reference/pandas/bar.html). So you could rename the ticks first and the plot the bars as a workaround. – mosc9575 May 04 '23 at 18:50
  • 1
    I created a new issue [#1066](https://github.com/holoviz/hvplot/issues/1066) to document this. – mosc9575 May 04 '23 at 19:09

0 Answers0