holoviews
holoviews copied to clipboard
Plotting options doesn't work properly for plotly backend
I found many options in plots doesn't work in plotly backend. Matplotlib backend generally show desirable output, while bokeh sometimes fails too.
Tested:
plotly | bokeh | matplotlib | |
---|---|---|---|
ticks = n | N | Y | Y |
ticks = list | Y | Y | Y |
logx | xlim become (0,10^xmax) | no ticks | Y |
logy | ylim become (0,10^ymax) | Y | Y |
xaxis | N | Y | Y |
yaxis | N | Y | Y |
xlabel | Y | Y | Y |
ylabel | Y | Y | Y |
xrotation | N | Y | Y |
yrotation | N | Y | Y |
# imports
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('plotly', 'bokeh', 'matplotlib')
# plots some points of exponential function
xs = np.linspace(0, np.pi*2)
points = hv.Points(np.exp(xs))
# a list of ploting options
axes_opts = [
('N xticks', {'xticks': 3}),
('N yticks', {'yticks': 3}),
('List xticks', {'xticks': [0, 5, 10, 20, 50, 100]}),
('List yticks', {'yticks': [0, 50, 100, 200, 500, 1000]})
]
# plot and export plots using different backends
backend = 'plotly' # or 'bokeh', 'matplotlib'
hv.output(backend=backend)
layout = hv.Layout([points.relabel(group=group).options(**opts)
for group, opts in axes_opts]).cols(2)
hv.save(layout, 'layout-%s-log.png' % backend, dpi=300)
axes_opts = [
('logx', {'logx': True}),
('logy', {'logy': True}),
]
axes_opts = [
('xaxis', {'xaxis':'top'}),
('yaxis', {'yaxis':'right'}),
('xlabel', {'xlabel':'xlabel'}),
('ylabel', {'ylabel':'ylabel'}),
('xrotation', {'xrotation':90}),
('yrotation', {'yrotation':90}),
]
I also found that dpi in hv.save only works for matplotlib backend. Changing dpi does nothing for plotly and bokeh backends.
Thanks for the detailed list, this will be helpful. The Plotly backend was always more of a prototype and used to have a big disclaimer saying as much. We probably have some funding to make improvements here so this issue will be quite helpful in ticking off these features.
Note that I would only expect dpi
to work for the matplotlib backend, as Bokeh options are specified in pixels directly, not inches.
Note that I would only expect dpi to work for the matplotlib backend, as Bokeh options are specified in pixels directly, not inches.
True, although it would be nice if plotly and bokeh png exports had options to control the dpi (they currently don't). P.S.: GitHub seems to be very confused about timezones today.
@philippjfr I find Plotly generally works better than bokeh most of the time. For example, Plotly can automatically recognise date columns as time series while bokeh doesn't and it will show every row as a tick label which is a mess. The hover tool in Plotly is included by default and exported images do not contain the annoying tool bar. I think bokeh should do the same.
@jbednar @philippjfr Is there no way to control dpi in Plotly or bokeh backend in holoviews currently? Is there any workaround by importing Plotly or bokeh together with holoviews? Perhaps I should put this in a separate issue.
Just tried logy with plotly, still an issue. Any tips regarding which code is related to this?
I just ran into this issue where indeed the plot bounds are wrong on Plotly when using log axis. But, when you press autoscale inside the plot, the correct bounds are shown. Manually setting the limits seems to also work correctly, it's just the initial bounds that wrong.
For a while we had one of the main Plotly developers maintaining the Plotly backend, but he's moved on, and the core HoloViews development team currently only uses Plotly for a very few plot types (typically 3D) not supported by Bokeh. So this is definitely a case where Plotly users in the community can step in by looking at the Plotly definitions in holoviews/holoviews/plotting/plotly/ and fix missing or broken options. There's no reason the Plotly backend can't be as well supported as the Bokeh one!