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

Can't export HTML with Plotly backend #3683

Closed
HuangJunye opened this issue May 2, 2019 · 8 comments
Closed

Can't export HTML with Plotly backend #3683

HuangJunye opened this issue May 2, 2019 · 8 comments
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@HuangJunye
Copy link

When I use Plotly as backend, the exported HTML does not shows the plot correctly. When I click on the exported HTML file, only ''Drawing..." is displayed.

This is the python code I used in Jupyter notebook

import NumPy as np
import pandas as pd
import holoviews as hv
hv.extension('plotly')
df = pd.DataFrame()
df['x'] = np.arange(10)
df['y'] = np.arange(10)
plot = hv.Curve(df, 'x','y')
hv.save(plot, 'plot.html')

This is the source code of the exported HTML

<script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};</script>
<div id="120902428136.loading" style="color: rgb(50,50,50);">Drawing...</div><div id="120902428136" style="height: 600; width: 800;" class="plotly-graph-div"></div><script type="text/javascript">  var plotly = window._Plotly || window.Plotly;plotly.plot("120902428136", [{"legendgroup": "Curve", "line": {"color": "#30a2da", "width": 2}, "mode": "lines", "name": "", "showlegend": false, "x": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "y": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "scatter", "uid": "2d9897e8-f9cb-4d8a-bdc3-fbf018ed4930"}], {"height": 400, "margin": {"b": 50, "l": 50, "pad": 4, "r": 50, "t": 50}, "title": {"text": ""}, "width": 400, "xaxis": {"range": [0.0, 9.0], "title": {"text": "x"}}, "yaxis": {"range": [0.0, 9.0], "title": {"text": "y"}}}, {"showLink": false}).then(function() {
    var elem = document.getElementById("120902428136.loading"); elem.parentNode.removeChild(elem);
})</script>

It seems the data is included in the HTML file but for some reasons it is not shown.

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label May 2, 2019
@HuangJunye
Copy link
Author

I accidentally found out some plots can be exported to html using plotly backend. It seems that export works when there is extra key dimensions. In this case, when I plot using ds.to, the extra key dimension will be shown as drop down menu or slider. (I think holoviews automatically draws HoloMap instead of simple curve). Export works for this kind of plots.

# imports
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('plotly')

# create a dataframe
df = pd.DataFrame()
df['x'] = np.arange(10)
df['y'] = np.arange(10)
df.loc[0:4,'handle']=0
df.loc[5:9,'handle']=1

# convert dataframe to holoviews dataset
x = hv.Dimension('x')
y = hv.Dimension('y')
handle = hv.Dimension('handle')
ds_with_handle = hv.Dataset(df, [x, handle], y)
ds_without_handle = hv.Dataset(df, x, y)

# plot using dataset.to
plot_with_handle = ds_with_handle.to(hv.Curve, 'x','y')
plot_without_handle = ds_without_handle.to(hv.Curve, 'x','y')

#export
hv.save(plot_with_handle, 'plot_with_handle.html')
hv.save(plot_without_handle, 'plot_without_handle.html')
type(plot_with_handle)
Output: holoviews.core.spaces.HoloMap
type(plot_without_handle)
Output: holoviews.element.chart.Curve

The exported htmls:
plotly export problem.zip

Hope this information helps to fix the bug.

@philippjfr
Copy link
Member

Thanks @HuangJunye these detailed bug reports will indeed be very helpful.

@philippjfr
Copy link
Member

Fixed on master.

@philippjfr philippjfr added this to the v1.13.0 milestone Oct 1, 2019
@HuangJunye
Copy link
Author

@philippjfr That's great to know! Thanks!

@drrmmng
Copy link
Contributor

drrmmng commented Oct 27, 2019

Fixed on master.

Will this be in the next release?
In the meantime, is there a workaround?

@jbednar
Copy link
Member

jbednar commented Oct 28, 2019

Yes, that should be in the next release. In the meantime, you can install from master using something like pip install git+https://github.com/pyviz/holoviews.git@master#egg=holoviews

@sameerCoder
Copy link

Hi,
with version master holoviews i.e holoviews versions- 1.13.0a13 ,
The latitude and longitude hover is showing value as Longitude: 9.641e+6 , Latitude:2.286e+6 like this format.

@jbednar
Copy link
Member

jbednar commented Oct 28, 2019

The latitude and longitude hover is showing value as Longitude: 9.641e+6 , Latitude:2.286e+6 like this format.

That comment doesn't seem related to this issue...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

5 participants