examples/heatmaps.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <script>\n",
" requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})\n",
" </script>\n",
"\n",
"\n",
"<div id=\"538b8031-8157-4473-aaab-221d4569c87b\" style=\"height: 100%; width: 100%;\"></div>\n",
"\n",
"<script>\n",
" require(['plotly'], function(Plotly) { \n",
"Plotly.newPlot(\n",
" '538b8031-8157-4473-aaab-221d4569c87b',\n",
" [{\"z\":[[1,20,30],[20,1,60],[30,60,1]],\"type\":\"heatmap\"}],\n",
" {},\n",
" {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
")\n",
"\n",
"window.addEventListener('resize', function() {\n",
" Plotly.Plots.resize(document.getElementById('538b8031-8157-4473-aaab-221d4569c87b'))\n",
"})\n",
" }) \n",
"</script>"
],
"text/plain": [
"#<Plotly::Offline::HTML:0x007ff4ac144a30 @id=\"538b8031-8157-4473-aaab-221d4569c87b\", @data=[{:z=>[[1, 20, 30], [20, 1, 60], [30, 60, 1]], :type=>:heatmap}], @layout={}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Basic Heatmap\n",
"require 'rbplotly'\n",
"\n",
"z = [\n",
" [1, 20, 30],\n",
" [20, 1, 60],\n",
" [30, 60, 1]\n",
"]\n",
"\n",
"data = [{\n",
" z: z,\n",
" type: :heatmap\n",
"}]\n",
"\n",
"plot = Plotly::Plot.new(data: data)\n",
"plot.show"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <script>\n",
" requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})\n",
" </script>\n",
"\n",
"\n",
"<div id=\"30fe907e-b3ae-4b61-ae76-e40bd75080c4\" style=\"height: 100%; width: 100%;\"></div>\n",
"\n",
"<script>\n",
" require(['plotly'], function(Plotly) { \n",
"Plotly.newPlot(\n",
" '30fe907e-b3ae-4b61-ae76-e40bd75080c4',\n",
" [{\"z\":[[0,6,5,5,3,9,6,6,9,7],[6,3,2,5,9,1,4,6,7,4],[7,6,8,2,1,0,0,1,3,7],[6,8,8,4,3,1,0,8,5,3],[1,2,4,0,2,6,4,2,7,6],[3,2,9,6,2,7,5,6,1,5],[2,0,3,4,4,8,6,9,2,9],[3,5,0,6,7,0,8,6,6,0],[0,8,3,9,7,6,5,0,9,9],[6,4,3,5,2,8,2,8,6,8]],\"type\":\"heatmap\",\"x\":[\"x1\",\"x2\",\"x3\",\"x4\",\"x5\",\"x6\",\"x7\",\"x8\",\"x9\",\"x10\"],\"y\":[\"y1\",\"y2\",\"y3\",\"y4\",\"y5\",\"y6\",\"y7\",\"y8\",\"y9\",\"y10\"]}],\n",
" {\"width\":500,\"height\":500},\n",
" {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
")\n",
"\n",
"window.addEventListener('resize', function() {\n",
" Plotly.Plots.resize(document.getElementById('30fe907e-b3ae-4b61-ae76-e40bd75080c4'))\n",
"})\n",
" }) \n",
"</script>"
],
"text/plain": [
"#<Plotly::Offline::HTML:0x007ff4ac82e0d0 @id=\"30fe907e-b3ae-4b61-ae76-e40bd75080c4\", @data=[{:z=>[[0, 6, 5, 5, 3, 9, 6, 6, 9, 7], [6, 3, 2, 5, 9, 1, 4, 6, 7, 4], [7, 6, 8, 2, 1, 0, 0, 1, 3, 7], [6, 8, 8, 4, 3, 1, 0, 8, 5, 3], [1, 2, 4, 0, 2, 6, 4, 2, 7, 6], [3, 2, 9, 6, 2, 7, 5, 6, 1, 5], [2, 0, 3, 4, 4, 8, 6, 9, 2, 9], [3, 5, 0, 6, 7, 0, 8, 6, 6, 0], [0, 8, 3, 9, 7, 6, 5, 0, 9, 9], [6, 4, 3, 5, 2, 8, 2, 8, 6, 8]], :type=>:heatmap, :x=>[\"x1\", \"x2\", \"x3\", \"x4\", \"x5\", \"x6\", \"x7\", \"x8\", \"x9\", \"x10\"], :y=>[\"y1\", \"y2\", \"y3\", \"y4\", \"y5\", \"y6\", \"y7\", \"y8\", \"y9\", \"y10\"]}], @layout={:width=>500, :height=>500}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"require 'rbplotly'\n",
"\n",
"n = 10\n",
"data = {\n",
" x: (1..n).map { |i| \"x#{i}\" },\n",
" y: (1..n).map { |i| \"y#{i}\" },\n",
" z: (1..n).map { (1..n).map { rand(10) } },\n",
" type: :heatmap\n",
"}\n",
"\n",
"layout = {\n",
" width: 500,\n",
" height: 500\n",
"}\n",
"\n",
"plot = Plotly::Plot.new(data: [data], layout: layout)\n",
"plot.show"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Ruby 2.3.1",
"language": "ruby",
"name": "ruby"
},
"language_info": {
"file_extension": ".rb",
"mimetype": "application/x-ruby",
"name": "ruby",
"version": "2.3.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}