{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
":dep plotly = { version = \">=0.7.0\" }\n",
":dep itertools-num = \"0.1.3\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"extern crate plotly;\n",
"extern crate rand_distr;\n",
"extern crate itertools_num;\n",
"extern crate itertools;"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"use itertools_num::linspace;\n",
"use plotly::common::{\n",
" ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,\n",
"};\n",
"use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};\n",
"use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};\n",
"use rand_distr::{Distribution, Normal, Uniform};"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
" <div id=\"LbkgUVmz2gqtoB3MWoay\" class=\"plotly-graph-div\" style=\"height:100%; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" require(['https://cdn.plot.ly/plotly-2.2.1.min.js'], function(Plotly) {\n",
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
"\n",
" if (document.getElementById(\"LbkgUVmz2gqtoB3MWoay\")) {\n",
" var trace_0 = {\"type\":\"scatter\",\"mode\":\"markers\",\"x\":[1,2,3,4,5,6,7,8,9,10],\"y\":[1.0,4.0,9.0,16.0,25.0,36.0,49.0,64.0,81.0,100.0]};\n",
"var data = [trace_0];\n",
"var layout = {\"height\":525};\n",
" Plotly.newPlot(\n",
" 'LbkgUVmz2gqtoB3MWoay',\n",
" data,\n",
" layout,\n",
" {\"responsive\": true}\n",
" ).then(function(){\n",
" var gd = document.getElementById('LbkgUVmz2gqtoB3MWoay');\n",
" var x = new MutationObserver(function (mutations, observer) { {\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') { {\n",
" console.log([gd, 'removed!']);\n",
" Plotly.purge(gd);\n",
" observer.disconnect();\n",
" } }\n",
" } });\n",
"\n",
" // Listen for the removal of the full notebook cells\n",
" var notebookContainer = gd.closest('#notebook-container');\n",
" if (notebookContainer) { {\n",
" x.observe(notebookContainer, {childList: true});\n",
" } }\n",
"\n",
" // Listen for the clearing of the current output cell\n",
" var outputEl = gd.closest('.output');\n",
" if (outputEl) { {\n",
" x.observe(outputEl, {childList: true});\n",
" } } })\n",
" };\n",
" });\n",
" </script>\n",
"</div>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"let n: usize = 100;\n",
"let t = vec![1,2,3,4,5,6,7,8,9,10];\n",
"let y = t.iter().map(|v| (*v as f64).powf(2.0)).collect::<Vec<f64>>();\n",
"let trace = Scatter::new(t,y).mode(Mode::Markers);\n",
"let mut plot = Plot::new();\n",
"plot.add_trace(trace);\n",
"let layout = Layout::new().height(525);\n",
"plot.set_layout(layout);\n",
"plot.notebook_display();"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Rust",
"language": "rust",
"name": "rust"
},
"language_info": {
"codemirror_mode": "rust",
"file_extension": ".rs",
"mimetype": "text/rust",
"name": "Rust",
"pygment_lexer": "rust",
"version": ""
}
},
"nbformat": 4,
"nbformat_minor": 4
}