{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": ["// can\u0027t yet format YamlFrontmatter ([\"title: 3D line charts\"; \"category: 3D Charts\"; \"categoryindex: 4\"; \"index: 2\"], Some { StartLine = 2 StartColumn = 0 EndLine = 6 EndColumn = 8 }) to pynb markdown\n", "\n"] } , { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": ["#r \"nuget: Plotly.NET, 2.0.0-preview.6\"\n", "#r \"nuget: Plotly.NET.Interactive, 2.0.0-preview.6\"\n"] } , { "cell_type": "markdown", "metadata": {}, "source": ["# 3D line charts\n", "\n", "[![Binder](https://plotly.net/img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath=3_1_3d-line-plots.ipynb)\u0026emsp;\n", "[![Script](https://plotly.net/img/badge-script.svg)](https://plotly.net/3_1_3d-line-plots.fsx)\u0026emsp;\n", "[![Notebook](https://plotly.net/img/badge-notebook.svg)](https://plotly.net/3_1_3d-line-plots.ipynb)\n", "\n", "*Summary:* This example shows how to create three-dimensional scatter charts in F#.\n", "\n", "let\u0027s first create some data for the purpose of creating example charts:\n"] } , { "cell_type": "code", "metadata": {}, "execution_count": 3, "outputs": [], "source": ["open Plotly.NET \n", "open System\n", " \n", "let c = [0. .. 0.5 .. 15.]\n", "\n", "let x,y,z = \n", " c\n", " |\u003e List.map (fun i -\u003e\n", " let i\u0027 = float i \n", " let r = 10. * Math.Cos (i\u0027 / 10.)\n", " (r*Math.Cos i\u0027,r*Math.Sin i\u0027,i\u0027)\n", " )\n", " |\u003e List.unzip3\n"] } , { "cell_type": "markdown", "metadata": {}, "source": ["A Scatter3 chart shows a three-dimensional spinnable view of your data.\n", "When using `Lines_Markers` as the mode of the chart, you additionally render a line between the points:\n"] } , { "cell_type": "code", "metadata": {}, "execution_count": 4, "outputs": [], "source": ["let scatter3dLine = \n", " Chart.Scatter3d(x,y,z,StyleParam.Mode.Lines_Markers)\n", " |\u003e Chart.withX_AxisStyle(\"x-axis\")\n", " |\u003e Chart.withY_AxisStyle(\"y-axis\")\n", " |\u003e Chart.withZ_AxisStyle(\"z-axis\")\n", " |\u003e Chart.withSize(800.,800.)\n"] } , { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [ { "data": { "text/html": ["\u003cdiv id=\"d48ee615-e3f1-4425-b8e2-a11dde6245d2\" style=\"width: 800px; height: 800px;\"\u003e\u003c!-- Plotly chart will be drawn inside this DIV --\u003e\u003c/div\u003e", "", "\u003cscript type=\"text/javascript\"\u003e", "", "", " var renderPlotly_d48ee615e3f14425b8e2a11dde6245d2 = function() {", " var fsharpPlotlyRequire = requirejs.config({context:\u0027fsharp-plotly\u0027,paths:{plotly:\u0027https://cdn.plot.ly/plotly-latest.min\u0027}}) || require;", " fsharpPlotlyRequire([\u0027plotly\u0027], function(Plotly) {", "", "", " var data = [{\"type\":\"scatter3d\",\"x\":[10.0,8.764858122060915,5.3760304484812105,0.699428991431538,-4.078516059742164,-7.762380006776013,-9.457759559629629,-8.796818588044248,-6.020456431562834,-1.8981046678556164,2.4893698743024015,6.041583606256742,7.924627339505819,7.774455867055686,5.766162492106399,2.5362920361842747,-1.0137084976470045,-3.9731770939413367,-5.663676531805762,-5.800381805436716,-4.533522819483132,-2.3661340757417872,0.020074794419808174,1.9742392407015044,3.0577702559255746,3.1462811058452385,2.427409510770794,1.302916035546942,0.23240834306912295,-0.42769357063721014,-0.5373819709641076],\"y\":[0.0,4.788263815209447,8.372671348444594,9.862941931402888,8.911720173488927,5.798670944701264,1.3481709304529075,-3.2951619221615798,-6.970612585921842,-8.802141619140079,-8.415352216177444,-6.014904288506064,-2.306115620213046,1.7125353726077581,5.024910671806752,6.86324142009979,6.892925283704576,5.269880365378672,2.561769585348826,-0.43714135926897707,-2.9393586065447344,-4.37711141115013,-4.535916791549611,-3.576112184549465,-1.9443135767963393,-0.2091277735131711,1.123941901777903,1.7603416439605064,1.6837070198341995,1.1265744325858227,0.4599954209124893],\"z\":[0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,12.0,12.5,13.0,13.5,14.0,14.5,15.0],\"mode\":\"lines+markers\",\"line\":{},\"marker\":{}}];", " var layout = {\"scene\":{\"xaxis\":{\"title\":\"x-axis\"},\"yaxis\":{\"title\":\"y-axis\"},\"zaxis\":{\"title\":\"z-axis\"}},\"width\":800.0,\"height\":800.0};", " var config = {};", " Plotly.newPlot(\u0027d48ee615-e3f1-4425-b8e2-a11dde6245d2\u0027, data, layout, config);", "", "});", " };", " if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {", " var script = document.createElement(\"script\");", " script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");", " script.onload = function(){", " renderPlotly_d48ee615e3f14425b8e2a11dde6245d2();", " };", " document.getElementsByTagName(\"head\")[0].appendChild(script);", " }", " else {", " renderPlotly_d48ee615e3f14425b8e2a11dde6245d2();", " }", "", "\u003c/script\u003e", "", ""] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" }], "source": ["scatter3dLine\n"] }], "metadata": { "kernelspec": {"display_name": ".NET (F#)", "language": "F#", "name": ".net-fsharp"}, "langauge_info": { "file_extension": ".fs", "mimetype": "text/x-fsharp", "name": "C#", "pygments_lexer": "fsharp", "version": "4.5" } }, "nbformat": 4, "nbformat_minor": 1 }