Created
May 15, 2014 01:43
-
-
Save jackparmer/65b6f3d25616f9fa1530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Plotly graph in IRKernel" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "library(IRdisplay)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 22 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "library(plotly)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 24 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "p <- plotly(username='rAPI', key='yu680v5eii')", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 25 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "size <- 100\nx <- seq(-2*pi, 2*pi, length=size)\ny <- seq(-2*pi, 2*pi, length=size)\nz <- matrix(0, size, size)\nfor(i in 1:size) {\n for(j in 1:size) {\n r2 <- x[i]^2 + y[j]^2\n z[i, j] <- sin(x[i])*cos(y[j])*sin(r2)/log(r2+1)\n }\n}\n\ntrace0 <- list(x = x, y = y, z = z, type = \"contour\")\n\nresponse <- p$plotly(trace0, kwargs=list(filename=\"simple-contour\", fileopt=\"overwrite\"))", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 26 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "plotly_iframe <- function(url) {\n # set width and height from options or default square\n w <- \"600\"\n h <- \"600\"\n html <- paste(\"<iframe height=\\\"\", h, \"\\\" id=\\\"igraph\\\" scrolling=\\\"no\\\" seamless=\\\"seamless\\\"\\n\\t\\t\\t\\tsrc=\\\"\", \n url, \"\\\" width=\\\"\", w, \"\\\" frameBorder=\\\"0\\\"></iframe>\", sep = \"\")\n return(html)\n}", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 27 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "display_html( plotly_iframe( response$url ) )", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<iframe height=\"600\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\"\n\t\t\t\tsrc=\"https://plot.ly/~rapi/75\" width=\"600\" frameBorder=\"0\"></iframe>", | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"prompt_number": 28 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment