{ "metadata": { "name": "", "signature": "sha256:7c641e9f216a08705d09747e7aa6525305bfbaadfa9d80f4184d7d4bc7d58b18" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import plotly\n", "plotly.__version__" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 1, "text": [ "'1.0.33'" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "import plotly.plotly as py\n", "import plotly.tools as tls\n", "from plotly.graph_objs import *\n", "help(Marker)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on class Marker in module plotly.graph_objs.graph_objs:\n", "\n", "class Marker(PlotlyDict)\n", " | A dictionary-like object representing marker(s) style in plotly.\n", " | \n", " | \n", " | Quick method reference:\n", " | \n", " | Marker.update(changes)\n", " | Marker.strip_style()\n", " | Marker.get_data()\n", " | Marker.to_graph_objs()\n", " | Marker.validate()\n", " | Marker.to_string()\n", " | Marker.force_clean()\n", " | \n", " | Valid keys:\n", " | \n", " | color [required=False] (value=array-like of string describing color):\n", " | Sets the color of the face of the marker object. If 'color' is\n", " | linked to a list or an array of numbers, color values are mapped to\n", " | individual marker points in the same order as in the data lists or\n", " | arrays. To set the color of the marker's bordering line, use the\n", " | 'line' key in Marker.\n", " | \n", " | Examples:\n", " | [\"'green'\", \"'rgb(0, 255, 0)'\", \"'rgba(0, 255, 0, 0.3)'\",\n", " | \"'hsl(120,100%,50%)'\", \"'hsla(120,100%,50%,0.3)'\"]\n", " | \n", " | size [required=False] (value=number: x > 0, or list of these numbers):\n", " | Sets the size of the markers (in pixels). If 'size' is linked to a\n", " | list or an array of numbers, size values are mapped to individual\n", " | marker points in the same order as in the data lists or arrays.\n", " | \n", " | symbol [required=False] (value='dot' | 'cross' | 'diamond' | 'square' |\n", " | 'triangle-down' | 'triangle-left' | 'triangle-right' | 'triangle-up' |\n", " | 'x' OR list of these string values):\n", " | The symbol that is drawn on the plot for each marker. Supported only\n", " | in scatter trace. If 'symbol' is linked to a list or an array of\n", " | numbers, symbol values are mapped to individual marker points in the\n", " | same order as in the data lists or arrays.\n", " | \n", " | line [required=False] (value=Line object | dictionary-like):\n", " | A dictionary-like object describing the line belonging to the\n", " | marker. For example, the line around each point in a scatter trace\n", " | or the line around each bar in a bar trace.\n", " | \n", " | For more, run `help(plotly.graph_objs.Line)`\n", " | \n", " | opacity [required=False] (value=number: x in [0, 1], or list of these\n", " | numbers):\n", " | Sets the opacity, or transparency also known as the alpha channel of\n", " | colors) of the marker points. If the marker points' color is given\n", " | in terms of 'rgba' color model, this does not need to be defined. If\n", " | 'opacity' is linked to a list or an array of numbers, opacity values\n", " | are mapped to individual marker points in the same order as in the\n", " | data lists or arrays.\n", " | \n", " | colorscale [required=False] (value=array_like of value-color pairs |\n", " | 'Greys' | 'Greens' | 'Bluered' | 'Hot' | 'Picnic' | 'Portland' | 'Jet' |\n", " | 'RdBu' | 'Blackbody' | 'Earth' | 'Electric' | 'YIOrRd' | 'YIGnBu'):\n", " | The color scale. The strings are pre-defined color scales. For\n", " | custom color scales, define a list of color-value pairs, where the\n", " | first element of the pair corresponds to a normalized value of the y\n", " | coordinates (for scatter traces) from 0-1 and the second element of\n", " | pair corresponds to a color.\n", " | \n", " | sizemode [required=False] (value='diameter' | 'area'):\n", " | Scale the size each points with respect to diameter or area. Applies\n", " | only to scatter traces.\n", " | \n", " | sizeref [required=False] (value=number: x >= 0):\n", " | Select scale factor for the size of each point. Applies only to\n", " | scatter traces.\n", " | \n", " | maxdisplayed [required=False] (value=number: x >= 0):\n", " | Set maximum number of displayed points for this trace. Applies only\n", " | to scatter traces.\n", " | \n", " | Method resolution order:\n", " | Marker\n", " | PlotlyDict\n", " | __builtin__.dict\n", " | __builtin__.object\n", " | \n", " | Methods inherited from PlotlyDict:\n", " | \n", " | __init__(self, *args, **kwargs)\n", " | \n", " | force_clean(self, caller=True)\n", " | Attempts to convert to graph_objs and call force_clean() on values.\n", " | \n", " | Calling force_clean() on a PlotlyDict will ensure that the object is\n", " | valid and may be sent to plotly. This process will also remove any\n", " | entries that end up with a length == 0.\n", " | \n", " | Careful! This will delete any invalid entries *silently*.\n", " | \n", " | get_data(self)\n", " | Returns the JSON for the plot with non-data elements stripped.\n", " | \n", " | get_ordered(self, caller=True)\n", " | \n", " | strip_style(self)\n", " | Strip style from the current representation.\n", " | \n", " | All PlotlyDicts and PlotlyLists are guaranteed to survive the\n", " | stripping process, though they made be left empty. This is allowable.\n", " | \n", " | Keys that will be stripped in this process are tagged with\n", " | `'type': 'style'` in the INFO dictionary listed in graph_objs_meta.py.\n", " | \n", " | This process first attempts to convert nested collections from dicts\n", " | or lists to subclasses of PlotlyList/PlotlyDict. This process forces\n", " | a validation, which may throw exceptions.\n", " | \n", " | Then, each of these objects call `strip_style` on themselves and so\n", " | on, recursively until the entire structure has been validated and\n", " | stripped.\n", " | \n", " | to_graph_objs(self, caller=True)\n", " | Walk obj, convert dicts and lists to plotly graph objs.\n", " | \n", " | For each key in the object, if it corresponds to a special key that\n", " | should be associated with a graph object, the ordinary dict or list\n", " | will be reinitialized as a special PlotlyDict or PlotlyList of the\n", " | appropriate `kind`.\n", " | \n", " | to_string(self, level=0, indent=4, eol='\\n', pretty=True, max_chars=80)\n", " | Returns a formatted string showing graph_obj constructors.\n", " | \n", " | Example:\n", " | \n", " | print obj.to_string()\n", " | \n", " | Keyword arguments:\n", " | level (default = 0) -- set number of indentations to start with\n", " | indent (default = 4) -- set indentation amount\n", " | eol (default = '\n", " | ') -- set end of line character(s)\n", " | pretty (default = True) -- curtail long list output with a '...'\n", " | max_chars (default = 80) -- set max characters per line\n", " | \n", " | update(self, dict1=None, **dict2)\n", " | Update current dict with dict1 and then dict2.\n", " | \n", " | This recursively updates the structure of the original dictionary-like\n", " | object with the new entries in the second and third objects. This\n", " | allows users to update with large, nested structures.\n", " | \n", " | Note, because the dict2 packs up all the keyword arguments, you can\n", " | specify the changes as a list of keyword agruments.\n", " | \n", " | Examples:\n", " | # update with dict\n", " | obj = Layout(title='my title', xaxis=XAxis(range=[0,1], domain=[0,1]))\n", " | update_dict = dict(title='new title', xaxis=dict(domain=[0,.8]))\n", " | obj.update(update_dict)\n", " | obj\n", " | {'title': 'new title', 'xaxis': {'range': [0,1], 'domain': [0,.8]}}\n", " | \n", " | # update with list of keyword arguments\n", " | obj = Layout(title='my title', xaxis=XAxis(range=[0,1], domain=[0,1]))\n", " | obj.update(title='new title', xaxis=dict(domain=[0,.8]))\n", " | obj\n", " | {'title': 'new title', 'xaxis': {'range': [0,1], 'domain': [0,.8]}}\n", " | \n", " | This 'fully' supports duck-typing in that the call signature is\n", " | identical, however this differs slightly from the normal update\n", " | method provided by Python's dictionaries.\n", " | \n", " | validate(self, caller=True)\n", " | Recursively check the validity of the keys in a PlotlyDict.\n", " | \n", " | The valid keys constitute the entries in each object\n", " | dictionary in INFO stored in graph_objs_meta.py.\n", " | \n", " | The validation process first requires that all nested collections be\n", " | converted to the appropriate subclass of PlotlyDict/PlotlyList. Then,\n", " | each of these objects call `validate` and so on, recursively,\n", " | until the entire object has been validated.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from PlotlyDict:\n", " | \n", " | __dict__\n", " | dictionary for instance variables (if defined)\n", " | \n", " | __weakref__\n", " | list of weak references to the object (if defined)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes inherited from PlotlyDict:\n", " | \n", " | __metaclass__ = \n", " | A meta class for PlotlyDict class creation.\n", " | \n", " | The sole purpose of this meta class is to properly create the __doc__\n", " | attribute so that running help(Obj), where Obj is a subclass of PlotlyDict,\n", " | will return information about key-value pairs for that object.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from __builtin__.dict:\n", " | \n", " | __cmp__(...)\n", " | x.__cmp__(y) <==> cmp(x,y)\n", " | \n", " | __contains__(...)\n", " | D.__contains__(k) -> True if D has a key k, else False\n", " | \n", " | __delitem__(...)\n", " | x.__delitem__(y) <==> del x[y]\n", " | \n", " | __eq__(...)\n", " | x.__eq__(y) <==> x==y\n", " | \n", " | __ge__(...)\n", " | x.__ge__(y) <==> x>=y\n", " | \n", " | __getattribute__(...)\n", " | x.__getattribute__('name') <==> x.name\n", " | \n", " | __getitem__(...)\n", " | x.__getitem__(y) <==> x[y]\n", " | \n", " | __gt__(...)\n", " | x.__gt__(y) <==> x>y\n", " | \n", " | __iter__(...)\n", " | x.__iter__() <==> iter(x)\n", " | \n", " | __le__(...)\n", " | x.__le__(y) <==> x<=y\n", " | \n", " | __len__(...)\n", " | x.__len__() <==> len(x)\n", " | \n", " | __lt__(...)\n", " | x.__lt__(y) <==> x x!=y\n", " | \n", " | __repr__(...)\n", " | x.__repr__() <==> repr(x)\n", " | \n", " | __setitem__(...)\n", " | x.__setitem__(i, y) <==> x[i]=y\n", " | \n", " | __sizeof__(...)\n", " | D.__sizeof__() -> size of D in memory, in bytes\n", " | \n", " | clear(...)\n", " | D.clear() -> None. Remove all items from D.\n", " | \n", " | copy(...)\n", " | D.copy() -> a shallow copy of D\n", " | \n", " | fromkeys(...)\n", " | dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n", " | v defaults to None.\n", " | \n", " | get(...)\n", " | D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.\n", " | \n", " | has_key(...)\n", " | D.has_key(k) -> True if D has a key k, else False\n", " | \n", " | items(...)\n", " | D.items() -> list of D's (key, value) pairs, as 2-tuples\n", " | \n", " | iteritems(...)\n", " | D.iteritems() -> an iterator over the (key, value) items of D\n", " | \n", " | iterkeys(...)\n", " | D.iterkeys() -> an iterator over the keys of D\n", " | \n", " | itervalues(...)\n", " | D.itervalues() -> an iterator over the values of D\n", " | \n", " | keys(...)\n", " | D.keys() -> list of D's keys\n", " | \n", " | pop(...)\n", " | D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n", " | If key is not found, d is returned if given, otherwise KeyError is raised\n", " | \n", " | popitem(...)\n", " | D.popitem() -> (k, v), remove and return some (key, value) pair as a\n", " | 2-tuple; but raise KeyError if D is empty.\n", " | \n", " | setdefault(...)\n", " | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D\n", " | \n", " | values(...)\n", " | D.values() -> list of D's values\n", " | \n", " | viewitems(...)\n", " | D.viewitems() -> a set-like object providing a view on D's items\n", " | \n", " | viewkeys(...)\n", " | D.viewkeys() -> a set-like object providing a view on D's keys\n", " | \n", " | viewvalues(...)\n", " | D.viewvalues() -> an object providing a view on D's values\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes inherited from __builtin__.dict:\n", " | \n", " | __hash__ = None\n", " | \n", " | __new__ = \n", " | T.__new__(S, ...) -> a new object with type S, a subtype of T\n", "\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "colorscale= [[0, \"rgb(255,0,0)\"],[0.066667,\"rgb(204,0,0)\"],[0.13333,\"rgb(255,127,64)\"],\n", "[0.2,\"rgb(255,85,0)\"],[0.26667,\"rgb(255,170,0)\"],[0.33333,\"rgb(255,255,0)\"],[0.4,\"rgb(128,255,0)\"],\n", "[0.46667,\"rgb(0,255,0)\"],[0.53333,\"rgb(0,255,129)\"],[0.6,\"rgb(0,255,255)\"],[0.66667,\"rgb(0,170,255)\"],\n", "[0.73333,\"rgb(0,62,255)\"],[0.8,\"rgb(115,0,230)\"],[0.86667,\"rgb(103,0,204)\"],[0.93333,\"rgb(77,0,153)\"],\n", "[1,\"rgb(153,0,122)\"]]\n", "colorscale" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "[[0, 'rgb(255,0,0)'],\n", " [0.066667, 'rgb(204,0,0)'],\n", " [0.13333, 'rgb(255,127,64)'],\n", " [0.2, 'rgb(255,85,0)'],\n", " [0.26667, 'rgb(255,170,0)'],\n", " [0.33333, 'rgb(255,255,0)'],\n", " [0.4, 'rgb(128,255,0)'],\n", " [0.46667, 'rgb(0,255,0)'],\n", " [0.53333, 'rgb(0,255,129)'],\n", " [0.6, 'rgb(0,255,255)'],\n", " [0.66667, 'rgb(0,170,255)'],\n", " [0.73333, 'rgb(0,62,255)'],\n", " [0.8, 'rgb(115,0,230)'],\n", " [0.86667, 'rgb(103,0,204)'],\n", " [0.93333, 'rgb(77,0,153)'],\n", " [1, 'rgb(153,0,122)']]" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "data = Data([\n", " Scatter(\n", " x=[0, 1, 2, 3],\n", " y=[0.2, 0.1, -0.3, 0.8],\n", " name='wave0',\n", " mode='markers',\n", " marker=Marker(\n", " symbol='dot',\n", " line=Line(\n", " color='rgb(0,254,254)',\n", " width=2\n", " ),\n", " size=21,\n", " color=[0.2, 0.1, -0.3, 0.8],\n", " colorscale=colorscale\n", " )\n", " )\n", "])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "py.iplot(data, filename='colorscale-test')" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "fig_get = py.get_figure(\"https://plot.ly/~etpinard/324/wave0/\")\n", "\n", "print fig_get.to_string()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Figure(\n", " data=Data([\n", " Scatter(\n", " x=[0, 1, 2, 3],\n", " y=[0.2, 0.1, -0.3, 0.8],\n", " mode='markers',\n", " name='wave0',\n", " marker=Marker(\n", " color=[0.2, 0.1, -0.3, 0.8],\n", " size=21,\n", " symbol='dot',\n", " line=Line(\n", " color='rgb(0,254,254)',\n", " width=2\n", " ),\n", " colorscale=[[0, 'rgb(255,0,0)'], [0.066667, 'rgb(204,0,0)']...]\n", " )\n", " )\n", " ])\n", ")\n" ] } ], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "py.iplot(fig_get, filename='colorscale-test-replay')" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import display, HTML\n", "import urllib2\n", "url = 'https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css'\n", "display(HTML(urllib2.urlopen(url).read()))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }