Skip to content

Instantly share code, notes, and snippets.

@malhotrachetan
Created June 1, 2019 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malhotrachetan/06c766c5feefd5bbfd64e3a6aa24dd11 to your computer and use it in GitHub Desktop.
Save malhotrachetan/06c766c5feefd5bbfd64e3a6aa24dd11 to your computer and use it in GitHub Desktop.
Plotly on google colab/kaggle
def configure_plotly_browser_state():
import IPython
display(IPython.core.display.HTML('''
<script src="/static/components/requirejs/require.js"></script>
<script>
requirejs.config({
paths: {
base: '/static/base',
plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
},
});
</script>
'''))
import plotly.plotly as py
import numpy as np
from plotly.offline import init_notebook_mode, iplot
from plotly.graph_objs import Contours, Histogram2dContour, Marker, Scatter
configure_plotly_browser_state()
init_notebook_mode(connected=False)
x = np.random.randn(2000)
y = np.random.randn(2000)
iplot([Histogram2dContour(x=x, y=y, contours=Contours(coloring='heatmap')),
Scatter(x=x, y=y, mode='markers', marker=Marker(color='white', size=3, opacity=0.3))], show_link=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment