{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#

     3D scatter plots in Lightning" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Setup" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from lightning import Lightning\n", "\n", "from numpy import random, asarray, amin, concatenate, column_stack \n", "from seaborn import color_palette\n", "from sklearn import datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Connect to server" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Lightning initialized
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Connected to server at http://public.lightning-viz.org\n" ] }, { "data": { "application/javascript": [ "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\"Cannot find module '\"+o+\"'\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Random points with default styling" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 100\n", "x = random.rand(n)*100\n", "y = random.rand(n)*100\n", "z = random.rand(n)*100\n", "\n", "lgn.scatter3(x,y,z)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Random small red points" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 100\n", "x = random.rand(n)*100\n", "y = random.rand(n)*100\n", "z = random.rand(n)*100\n", "c = [240,117,145]\n", "\n", "lgn.scatter3(x,y,z,size=4,color=c)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Random points with all styling options" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 100\n", "x = random.rand(n)*100\n", "y = random.rand(n)*100\n", "z = random.rand(n)*100\n", "c = [asarray(color_palette('Blues', 100)[random.choice(range(100))])*255 for i in range(n)]\n", "s = random.rand(n)*8+1\n", "\n", "lgn.scatter3(x, y, z, color=c, size=s)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Fun with colors" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 500\n", "x = random.rand(n)*255\n", "y = random.rand(n)*255\n", "z = random.rand(n)*255\n", "c = column_stack((x,y,z))\n", "\n", "lgn.scatter3(x,y,z,color=c, size=3)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }