Skip to content

Instantly share code, notes, and snippets.

@arsenovic
Created July 30, 2014 20:13
Show Gist options
  • Save arsenovic/c2e82c7fc2554529580d to your computer and use it in GitHub Desktop.
Save arsenovic/c2e82c7fc2554529580d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:718fb61c2ef747fa379f87bf8b292bcda40f07450feb99ea11aa4034112ba173"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.display import HTML\n",
"import plotly.plotly as py \n",
"from pylab import * \n",
"import plotly.tools as tls \n",
"\n",
"plot(rand(100))\n",
"p=py.plot_mpl(gcf(), auto_open=False, filename='test')\n",
"\n",
"## standard embedding \n",
"e = tls.embed(p)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~arsenovic/184\" height=\"525\" width=\"100%\"></iframe>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0xd283bd0>"
]
}
],
"prompt_number": 63
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"##editable embedding, allows seamless interactive plotly-ness\n",
"def get_embed_n_edit(p, *args, **kwargs):\n",
" s = p.split('/')\n",
" s_edit = '/'.join([k for k in s[:-2]+[s[-1],s[-2]]])\n",
" e = tls.get_embed(p, *args, **kwargs)\n",
" return e.replace(p,s_edit)\n",
" \n",
"def embed_n_edit(p, *args, **kwargs):\n",
" return HTML(get_embed_n_edit(p, *args, **kwargs))\n",
"\n",
"embed_n_edit(p, height =800)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/184/~arsenovic\" height=\"800\" width=\"100%\"></iframe>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 64,
"text": [
"<IPython.core.display.HTML at 0xd213250>"
]
}
],
"prompt_number": 64
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# see the updated plot (once saved)\n",
"tls.embed(p)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~arsenovic/184\" height=\"525\" width=\"100%\"></iframe>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0xd0df810>"
]
}
],
"prompt_number": 66
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment