GithubHelp home page GithubHelp logo

plotly / plotly.py Goto Github PK

View Code? Open in Web Editor NEW
15.2K 278.0 2.5K 155.91 MB

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!

Home Page: https://plotly.com/python/

License: MIT License

Python 98.07% JavaScript 0.01% PostScript 1.71% TypeScript 0.21% CSS 0.01%
python d3 plotly plotlyjs webgl dashboard visualization graph-library plotly-dash jupyter-notebook sparkles regl declarative interactive

plotly.py's Introduction

plotly.py

Latest Release
User forum
PyPI Downloads
License

Quickstart

pip install plotly==5.21.0

Inside Jupyter (installable with pip install "jupyterlab>=3" "ipywidgets>=7.6"):

import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()

See the Python documentation for more examples.

Overview

plotly.py is an interactive, open-source, and browser-based graphing library for Python โœจ

Built on top of plotly.js, plotly.py is a high-level, declarative charting library. plotly.js ships with over 30 chart types, including scientific charts, 3D graphs, statistical charts, SVG maps, financial charts, and more.

plotly.py is MIT Licensed. Plotly graphs can be viewed in Jupyter notebooks, standalone HTML files, or integrated into Dash applications.

Contact us for consulting, dashboard development, application integration, and feature additions.



Installation

plotly.py may be installed using pip...

pip install plotly==5.21.0

or conda.

conda install -c plotly plotly=5.21.0

JupyterLab Support

For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip:

pip install "jupyterlab>=3" "ipywidgets>=7.6"

or conda:

conda install "jupyterlab>=3" "ipywidgets>=7.6"

The instructions above apply to JupyterLab 3.x. For JupyterLab 2 or earlier, run the following commands to install the required JupyterLab extensions (note that this will require node to be installed):

# JupyterLab 2.x renderer support
jupyter labextension install [email protected] @jupyter-widgets/jupyterlab-manager

Please check out our Troubleshooting guide if you run into any problems with JupyterLab.

Jupyter Notebook Support

For use in the Jupyter Notebook, install the notebook and ipywidgets packages using pip:

pip install "notebook>=5.3" "ipywidgets>=7.5"

or conda:

conda install "notebook>=5.3" "ipywidgets>=7.5"

Static Image Export

plotly.py supports static image export, using either the kaleido package (recommended, supported as of plotly version 4.9) or the orca command line utility (legacy as of plotly version 4.9).

Kaleido

The kaleido package has no dependencies and can be installed using pip...

pip install -U kaleido

or conda.

conda install -c conda-forge python-kaleido

Orca

While Kaleido is now the recommended image export approach because it is easier to install and more widely compatible, static image export can also be supported by the legacy orca command line utility and the psutil Python package.

These dependencies can both be installed using conda:

conda install -c plotly plotly-orca==1.3.1 psutil

Or, psutil can be installed using pip...

pip install psutil

and orca can be installed according to the instructions in the orca README.

Extended Geo Support

Some plotly.py features rely on fairly large geographic shape files. The county choropleth figure factory is one such example. These shape files are distributed as a separate plotly-geo package. This package can be installed using pip...

pip install plotly-geo==1.0.0

or conda

conda install -c plotly plotly-geo=1.0.0

Migration

If you're migrating from plotly.py v3 to v4, please check out the Version 4 migration guide

If you're migrating from plotly.py v2 to v3, please check out the Version 3 migration guide

Copyright and Licenses

Code and documentation copyright 2019 Plotly, Inc.

Code released under the MIT license.

Docs released under the Creative Commons license.

plotly.py's People

Contributors

aaronstiff avatar alexcjohnson avatar aneda avatar anmyachev avatar archmoj avatar bartbroere avatar bronsolo avatar chriddyp avatar cldougl avatar dependabot[bot] avatar emmanuelle avatar etpinard avatar hammadtheone avatar jackparmer avatar jbampton avatar joelostblom avatar jonmmease avatar kully avatar liamconnors avatar merenlin avatar nicholas-esterer avatar nicolaskruchten avatar renaudln avatar ry-v1 avatar smallstepman avatar sylwiaoliwia2 avatar tarzzz avatar theengineear avatar yankev avatar zfoltz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plotly.py's Issues

Matplotlib colorbars

Sorry, the examples I was going to show were giving errors, but I think it's because of calls to ax.imshow() and contourf() in matplotlib rather than just the colorbars per-se.

Bug: Disabling axis lines, ticks and ticks texts does not work when converting matplotlib plots to plotly

In my case I want that axis, axis lines, ticks and tick texts are disabled also after conversion from matplotlib to plotly i.e in graphs visible in plotly web pages.

Although it is very easy way to modify graphs from plotly GUI it unfortunately requires manual work that I try to avoid. I was just wandering is there any way to make it already when creating graphs in python&matplotlib. I tried to use e.g.

ax13.set_axis_off() -> this did not make any change in plotly. It worked well in matplotlib where it disabled axis, spines and tick texts.

ax13.spines["bottom"].set_color('none')
ax13.spines["top"].set_color('none')
ax13.spines["left"].set_color('none')
ax13.spines["right"].set_color('none')

-> with there I disabled spines (but not ticks nor tick texts) in plotly

ax13.tick_params.set_visible(False)
ax13.tick_params(colors='none')

-> these did not make any changes in plotly

So, is it possible to make
ax13.set_axis_off()
work also after conversion from matplotlib to plotly?

AttributeError: 'CompositeGenericTransform' object has no attribute 'contains_branch'

from matplotlib version 1.1.1

Traceback (most recent call last):
File "/Users/wdickerson/Desktop/plotly_test.py", line 14, in <module>
plot_url = py.plot_mpl(fig, filename='mpl-line-style')
File "/Library/Python/2.7/site-packages/plotly/plotly/plotly.py", line 262, in plot_mpl
fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
File "/Library/Python/2.7/site-packages/plotly/tools.py", line 345, in mpl_to_plotly
matplotlylib.Exporter(renderer).run(fig)
File "/Library/Python/2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 49, in run
self.crawl_fig(fig)
File "/Library/Python/2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 116, in crawl_fig
self.crawl_ax(ax)
File "/Library/Python/2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 123, in crawl_ax
self.draw_line(ax, line)
File "/Library/Python/2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 182, in draw_line
force_trans=force_trans)
File "/Library/Python/2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 96, in process_transform
if transform.contains_branch(trans):
AttributeError: 'CompositeGenericTransform' object has no attribute 'contains_branch'

AttributeError when importing plotly

I'm trying to use plotly, based on the tutorial here: http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s00_homepage/s00_homepage.ipynb

Seem to have the correct library and Python versions, although I get AttributeError while importing plotly. Wonder if anyone had the same problem, see versions and stacktrace below:

Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
Type "copyright", "credits" or "license" for more information.

IPython 2.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import numpy

In [2]: numpy.__version__
Out[2]: '1.8.1'

In [3]: import pandas

In [4]: pandas.__version__
Out[4]: '0.13.1'

In [5]: import plotly
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-c27a4132ad2e> in <module>()
----> 1 import plotly

/usr/local/lib/python2.7/dist-packages/plotly/__init__.py in <module>()
     29 from __future__ import absolute_import
     30 
---> 31 from plotly import plotly, graph_objs, tools, utils
     32 from plotly.version import __version__

/usr/local/lib/python2.7/dist-packages/plotly/plotly/__init__.py in <module>()
     10 from __future__ import absolute_import
     11 
---> 12 from plotly.plotly.plotly import *
     13 
     14 __all__ = ["sign_in", "update_plot_options", "get_plot_options",

/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py in <module>()
     27 from plotly.plotly import chunked_requests
     28 from plotly import utils
---> 29 from plotly import tools
     30 from plotly import exceptions
     31 from plotly import version

/usr/local/lib/python2.7/dist-packages/plotly/tools.py in <module>()
     18 from plotly import exceptions
     19 
---> 20 from . graph_objs import graph_objs
     21 
     22 # Warning format

/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/__init__.py in <module>()
     10 from __future__ import absolute_import
     11 
---> 12 from plotly.graph_objs.graph_objs import *
     13 
     14 __all__ = ["Data",

/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/graph_objs.py in <module>()
    279         return super(DictMeta, mcs).__new__(mcs, name, bases, attrs)
    280 
--> 281 @six.add_metaclass(ListMeta)
    282 class PlotlyList(list):
    283     """A container for PlotlyDicts, inherits from standard list.

AttributeError: 'module' object has no attribute 'add_metaclass'

Plotly compatibility issue with Python 2.6?

I'm running a Python script on an Amazon EC2 Linux Instance which uses the Python 2.6.9 interpreter. I installed plotly on the server, but when I try to import it I get the following error:

import plotly
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/site-packages/plotly/init.py", line 2, in
import graph_objs
File "/usr/lib/python2.6/site-packages/plotly/graph_objs/init.py", line 46, in
from graph_objs import *
File "/usr/lib/python2.6/site-packages/plotly/graph_objs/graph_objs.py", line 29, in
from .. import exceptions
ImportError: cannot import name exceptions

is_bar() in mpltools breaks stacked bar charts

The is_bar() function in mpltools appears to be checking whether a patch is a bar by checking the minimum y value to see if it's zero. I typically create stacked bars in matplotlib by changing the named parameter, "bottom" to be non-zero. However, the is_bar() check wipes out all patches for which the minimum y value is not zero. I'd be happy to submit some sample code that breaks when rendering using the iplot_mpl() function from plotly if necessary.

a few matplotlylib imperfections

Here is a list of matplotlylib imperfections I noticed while helping Randal Olson convert one of his matplotlib figure to plotly.

For more, refer to this notebook.

So, running

import plotly.plotly as py
py.plot_mpl(mpl_fig)

erroneously generates

  1. a plotly plot with axis lines (i.e. 'showline':True ), even if the original does not
  2. a plotly plot with axis ticks (i.e. ticks: 'inside'), even if the original does not
  3. dashed mpl grid lines are converted to dashed scatter traces (note that dashed grid lines are currently not supported in plotly)
  4. Annotations are not properly aligned (even their x-y positions match the original). For Randal's figure, this could be corrected by adding 'xanchor': 'left' to each annotation object.
  5. \n escape sequences in strings are not converted to <br> HTML tags
  6. mpl annotations outside the range of the axes should be converted to annotations containing 'xref: 'paper' and/or 'yref: 'paper' to make them visible
  7. Suffixes in axis tick labels vanish (is 'ticksuffix' a valid for x and y axes, like for radial axes?)

legend markers

when I create a legend

lg = ax.legend(loc = 'center left', bbox_to_anchor = (0, 0.8), fontsize=16)
lg.draw_frame(False)

the label markers are not converted properly.
mpl:
legend_mpl
plotly:
legend_ply

Wrap up 1.0

  • Config file
  • Style config
  • Graph meta docs (https://github.com/plotly/graph_reference/blob/master/graph_objs_meta.json) (Assigned to @chriddyp)
  • Figure(subplots=subplots) --> tools.get_subplots(rows=2, ...)
  • Auto-generate 'see help(Obj)' lines in doc from MetaDict
  • Default non-specified types to 'type': 'scatter' for Data instantiation.
  • Figure out if/how to validate values for each key... where to store this info, etc.
  • Add check and formatting for 'default' options with keys for doctrings in DictMeta

possible import order bug?

Hi,

I'm integrating plotly into a personal package we have called pyuvvis. Plotly is great by the way. I noticed that if I import plotly, then import the plotly portion of my package, everything works fine. EG:

 import plotly
 from pyuvvis.plotting.plotlywrapper import figure

However, if instead I had not imported plotly directly, I get an error (full traceback below):

from pyuvvis.plotting.plotlywrapper import figure

I am using enthought canopy as my primary python environment. We are using the most up-to-date version of plotly, requests and ipython. Any ideas of what's going on?


TypeError Traceback (most recent call last)
in ()
----> 1 from pyuvvis.plotting.plotlywrapper import figure

/home/adam/Desktop/pyuvvis/pyuvvis/plotting/plotlywrapper.py in ()
4 #import requests #bug if not imported
5 import logging
----> 6 import plotly.graph_objs as grobs
7 import numpy as np
8

/home/adam/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/plotly/init.py in ()
1 from . version import version
2 import graph_objs
----> 3 import plotly
4 import tools

/home/adam/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/plotly/plotly/init.py in ()
23
24 """
---> 25 from plotly import *
26
27 all = ["sign_in", "update_plot_options", "get_plot_options",

/home/adam/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/plotly/plotly/plotly.py in ()
15
16 """
---> 17 import requests
18 import chunked_requests
19 import json

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/site-packages/requests/init.py in ()
51 # Attempt to enable urllib3's SNI support, if possible
52 try:
---> 53 from requests.packages.urllib3.contrib import pyopenssl
54 pyopenssl.inject_into_urllib3()
55 except ImportError:

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/site-packages/requests/packages/init.py in ()
1 from future import absolute_import
2
----> 3 from . import urllib3

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/site-packages/requests/packages/urllib3/init.py in ()
36 pass
37
---> 38 logging.getLogger(name).addHandler(NullHandler())
39
40 def add_stderr_logger(level=logging.DEBUG):

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/logging/init.pyc in getLogger(name)
1555 """
1556 if name:
-> 1557 return Logger.manager.getLogger(name)
1558 else:
1559 return root

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/logging/init.pyc in getLogger(self, name)
1031 rv.manager = self
1032 self.loggerDict[name] = rv
-> 1033 self._fixupChildren(ph, rv)
1034 self._fixupParents(rv)
1035 else:

/home/adam/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/python2.7/logging/init.pyc in _fixupChildren(self, ph, alogger)
1085 for c in ph.loggerMap.keys():
1086 #The if means ... if not c.parent.name.startswith(nm)
-> 1087 if c.parent.name[:namelen] != name:
1088 alogger.parent = c.parent
1089 c.parent = alogger

TypeError: 'NoneType' object has no attribute 'getitem'

Missing dependencies when installing from pip ("requests")

Hello,

when i tried to install plotly using pip install plotly, I got:

Downloading/unpacking plotly
  Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB): 1  Downloading plotly-1.0.10.tar.gz (60kB):    Downloading plotly-1.0.10.tar.gz (60kB): 60kB downloaded
  Running setup.py (path:/home/dan/prac/.virtualenvs/work/build/plotly/setup.py) egg_info for package plotly
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/dan/prac/.virtualenvs/work/build/plotly/setup.py", line 3, in <module>
        exec (open('plotly/version.py').read())
      File "<string>", line 3, in <module>
    ImportError: No module named 'requests'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/dan/prac/.virtualenvs/work/build/plotly/setup.py", line 3, in <module>

    exec (open('plotly/version.py').read())

  File "<string>", line 3, in <module>

ImportError: No module named 'requests'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/dan/prac/.virtualenvs/work/build/plotly
Storing debug log for failure in /home/dan/.pip/pip.log

after installing "requests" using pip install requests, everything works fine.

should pkg_resources be a dependency?

trying to run plotly on a barebones, pip-less python distribution (the Arduino Yun) and ran into an ImportError for pkg_resources in graph_objs. Should it be an official setup.py dependency?

import error

Hi,
when I try to run this classic api example:

import plotly.plotly as py
from plotly.graph_objs import *

py.sign_in("myusername", "mykey")

data = Data([
    Bar(
        x=['giraffes', 'orangutans', 'monkeys'],
        y=[20, 14, 23]
    )
])

plot_url = py.plot(data, filename='basic-bar')

I get this error:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import plotly.plotly as py
  File "/usr/local/lib/python2.7/dist-packages/plotly/__init__.py", line 31, in <module>
    from plotly import plotly, graph_objs, tools, utils
  File "/usr/local/lib/python2.7/dist-packages/plotly/plotly/__init__.py", line 12, in <module>
    from plotly.plotly.plotly import *
  File "/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py", line 29, in <module>
    from plotly import tools
  File "/usr/local/lib/python2.7/dist-packages/plotly/tools.py", line 20, in <module>
    from . graph_objs import graph_objs
  File "/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/__init__.py", line 12, in <module>
    from plotly.graph_objs.graph_objs import *
  File "/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/graph_objs.py", line 281, in <module>
    @six.add_metaclass(ListMeta)
AttributeError: 'module' object has no attribute 'add_metaclass'

i'm on linux mint 16 - Python 2.7.5+
Any clues ?

saving layouts

is there any infrastructure to save and re-use layouts? couple things that would be nice

  • change my default layout

  • pass layout as argument to mpl_to_plotly, iplot_mpl, plot_mpl

  • have style files (like matplotlib.style)

    from plotly import style
    with style.context('ieeetrans'):
    py.iplot(....)

Plot.ly doesn't work in Python scripts compiled using PyInstaller

I'm trying to make executable / standalone programs using Python. I've used Qt designer to design the GUI, and then used PyQT (pyuic4) to convert the .UI files into .PY files which I can edit and build my Python scripts / program within.

Finally, once the program is built, I use PyInstaller to compile them into standalone executable files on Windows. Unfortunately, any graphs plotted using the Plot.ly module fail to work, but matplotlib graphs still do work. Any ideas?

Here's an example which you can see works as .PY file, but if you compile using PyInstaller will not:
http://pastebin.com/yTF1zbwn

Over here you can see the exact program I'm developing in Python where my problem is occurring:
https://github.com/RUGRLN/bioinformatics/tree/master/Hydropathy%20Plot

Any ideas?

double axis support

Hi,

I'm using this code to create a double axis plot:

from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA

x = arange(0,10)
y1 = rand(10)
y2 = rand(10)

fig = figure(figsize=(6,5))

ax1 = host_subplot(111, axes_class=AA.Axes)
ax2 = ax1.twinx()
plt.subplots_adjust(right=1)

ax1.plot(x, y1,'.-')
ax2.plot(x, y2,'r.-')

xlabel('x')

ax1.set_ylabel('y1', color='b')
ax2.set_ylabel('y2', color='r')

title('Double axis plot')
fig.tight_layout()

doubleaxisplot

Is there a neat way to convert this to plotly? When I pass the fig to iplot_mpl it returns a gnarly error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-475-abb745724116> in <module>()
     19 title('Double axis plot')
     20 fig.tight_layout()
---> 21 py.iplot_mpl(fig,filename='test')

//anaconda/lib/python2.7/site-packages/plotly/plotly/plotly.pyc in iplot_mpl(fig, resize, strip_style, update, **plot_options)
    222 
    223     """
--> 224     fig = tools.mpl_to_plotly(fig, resize=resize, strip_style=strip_style)
    225     if update and isinstance(update, dict):
    226         try:

//anaconda/lib/python2.7/site-packages/plotly/tools.pyc in mpl_to_plotly(fig, resize, strip_style, verbose)
    343     if _matplotlylib_imported:
    344         renderer = matplotlylib.PlotlyRenderer()
--> 345         matplotlylib.Exporter(renderer).run(fig)
    346         if resize:
    347             renderer.resize()

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.pyc in run(self, fig)
     47             import matplotlib.pyplot as plt
     48             plt.close(fig)
---> 49         self.crawl_fig(fig)
     50 
     51     @staticmethod

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.pyc in crawl_fig(self, fig)
    114                                        props=utils.get_figure_properties(fig)):
    115             for ax in fig.axes:
--> 116                 self.crawl_ax(ax)
    117 
    118     def crawl_ax(self, ax):

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.pyc in crawl_ax(self, ax)
    128                 if(hasattr(text, 'get_text') and text.get_text()):
    129                     self.draw_text(ax, text, force_trans=ax.transAxes,
--> 130                                    text_type=ttp)
    131             for artist in ax.artists:
    132                 # TODO: process other artists

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/mplexporter/exporter.pyc in draw_text(self, ax, text, force_trans, text_type)
    209                                     coordinates=coords,
    210                                     text_type=text_type,
--> 211                                     style=style, mplobj=text)
    212 
    213     def draw_patch(self, ax, patch, force_trans=None):

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/renderer.pyc in draw_text(self, **props)
    491         """
    492         self.msg += "    Attempting to draw an mpl text object\n"
--> 493         if not mpltools.check_corners(props['mplobj'], self.mpl_fig):
    494             warnings.warn("Looks like the annotation(s) you are trying \n" 
    495                           "to draw lies/lay outside the given figure size.\n\n"

//anaconda/lib/python2.7/site-packages/plotly/matplotlylib/mpltools.pyc in check_corners(inner_obj, outer_obj)
     37 
     38 def check_corners(inner_obj, outer_obj):
---> 39     inner_corners = inner_obj.get_window_extent().corners()
     40     outer_corners = outer_obj.get_window_extent().corners()
     41     if inner_corners[0][0] < outer_corners[0][0]:

//anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
    750             self._renderer = renderer
    751         if self._renderer is None:
--> 752             raise RuntimeError('Cannot get window extent w/o renderer')
    753 
    754         bbox, info, descent = self._get_layout(self._renderer)

RuntimeError: Cannot get window extent w/o renderer

plot_bgcolor in notebook

I'm running an ipython notebook that sets the default matplotlib background plot color as gray. The look fine; however, when I do:

py.iplot_mpl(fig)

The background color returns to white. Furthermore, if I explicitly pass a background color:

py.iplot_mpl(fig, plot_bgcolor='rgb(128,0,0)')

It is still white. Is py.iplot_mpl not passing the background color attribute through?

world_readable gives timeout/error

I found a recent bug which was hard for me to trace. When I use the world_readable=False keyword in iplot_mpl(), I get a timeout. Not going to post the plot call because it uses custom libraries. Do you guys also get this timeout in general when doing

iplot_mpl(fig, world_readable=False)

HTTPError Traceback (most recent call last)
in ()
2
3 range_timeplot(ts.wavelength_slices(8), ax=ax)
----> 4 py.iplot_mpl(fig, update=_pyupdate, resize=False, world_readable=False)

/home/glue/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/plotly/plotly/plotly.pyc in iplot_mpl(fig, resize, strip_style, update, *_plot_options)
231 return iplot(fig, *_plot_options)
232
--> 233
234 def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
235 """Replot a matplotlib figure with plotly.

/home/glue/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/plotly/plotly/plotly.pyc in iplot(figure_or_data, *_plot_options)
100 res = plot(figure_or_data, *_plot_options)
101 urlsplit = res.split('/')
--> 102 username, plot_id = urlsplit[-2][1:], urlsplit[-1] # TODO: HACKY!
103
104 embed_options = dict()

/home/glue/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/plotly/plotly/plotly.pyc in plot(figure_or_data, validate, *_plot_options)
183 res = _send_to_plotly(figure, *_plot_options)
184 if res['error'] == '':
--> 185 if plot_options['auto_open']:
186 try:
187 from webbrowser import open as wbopen

/home/glue/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/plotly/plotly/plotly.pyc in _send_to_plotly(figure, **plot_options)
568 return return_data['image']
569 else:
--> 570 try:
571 if ('content-type' in headers and
572 'json' in headers['content-type']):

/home/glue/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/models.pyc in raise_for_status(self)
793
794 if http_error_msg:
--> 795 raise HTTPError(http_error_msg, response=self)
796
797 def close(self):

Type error caused by json.loads(pkg_resources.resource_string)

I experience the following issue when importing plotly on Python 3 (3.3.0 on Windows, 3.4.0 on Linux). I haven't checked whether the error occurs on Python 2

plotly/graph_objs/graph_objs.py (in 4ed359e and maybe before) at lines 42ff cause a type error in the json module's loads function:

INFO = json.loads(resource_string('plotly',
                                  'graph_reference/graph_objs_meta.json')
                  object_pairs_hook=collections.OrderedDict)

TypeError: the JSON object must be str, not 'bytes'

Manually decoding the byte string with an added .decode('utf-8') solved my problems, but I'm not sure whether this will cause problems on Python 2 โ€“ I.e. I'm not aware of whether the return type of resource_string is different then.

Broken links to plotly notebooks

Hi - there are some broken links in the following files

It looks like the repositories have moved - not sure what the correct ones should be.

README.md
Get started with our guide book!: http://nbviewer.ipython.org/github/etpinard/plotly-python-doc/blob/1.0/s0_getting-started/s0_getting-started.ipynb

README.rst
Plotly and mpld3: http://nbviewer.ipython.org/github/plotly/python-api/blob/1.0/notebooks/Plotly%20and%20mpld3.ipynb
Plotly and Python: http://nbviewer.ipython.org/github/plotly/python-api/blob/1.0/notebooks/Plotly%20and%20Python.ipynb

screenshot - 150514 - 16 41 33

Deeper pandas integration

Hello,

I'd like to ask if there are plans to integrate plotly with pandas, similiar to ggplot style. Or is it impossible without changing "philisophy" of input?

Thank you

Have `iplot` return static image format of the plotly plot

The iplot function produces an HTML representation of a plotly plot for usage in the IPython notebook. IPython also supports converting notebooks to LaTeX/PDF documents through IPython.nbconvert. To get this to work, iplot would have to also display a static image format of the plot. It would be as simply as a call to display(Image(raw_image_data)) to include that in the notebook.

We (IPython dev team) is super excited about plotly and are more than willing to answer questions, etc. about the IPython integration.

Should py.Stream.write() accept trace objects ...

... instead of mere dictionaries?

Currently, in plotly.py

py.Stream.write(data) assumes that data is of the 'scatter' type:

https://github.com/plotly/python-api/blob/master/plotly/plotly/plotly.py#L435

So, to stream a heatmap trace object for example, we must add 'type':'heatmap' in the data dictionary argument. Example (the last cell of):

http://nbviewer.ipython.org/github/etpinard/plotly-misc-nbs/blob/etienne/mtl_do/stream-test.ipynb

Why not have py.Stream.write(obj) where obj is a trace object (e.g. Scatter, Bar, Heatmap) and infer which 'type' value is associated with each of them?

X ticks orientation 90deg rotated in subplot

Not sure how this happened.

screen shot 2014-08-21 at 7 21 26 pm

If it helps, here's my code:

fig = figure(figsize=(6,6))
for m in arange(0,len(data_IV_vs_T_vs_backgate)): 
    data = data_IV_vs_T_vs_backgate[m]
    [Rmatup, Vmatup, Imatup, Rmatdown, Vmatdown, Imatdown, T, B] = data
    ax = subplot(1,len(data_IV_vs_T_vs_backgate)+1,m+1)
    colormap = cm.jet
    colormap.set_gamma(1)
    color_cycle = [colormap(i) for i in np.linspace(0, 0.9, len(Rmatup))]
    ax.set_color_cycle(color_cycle)
    for (t,I,R) in zip(T, Imatup, Rmatup):
        label = 'T = ' + str(round(t*1e3)) + ' mK'
        plot(I,R,label=label)
    xlabel('$I_{dc} (A)$')
    ylabel('$R_{xx,ac} (\Omega)$')
    title(measnames[m])
width = 1000    # plot width in px
height = 500 # plot height in px
py.iplot_mpl(fig,filename='/superconductivity_XVII_LSM4_triton2/Rxxac_vs_Idc_vs_T_vs_Vbg', width=width, height=height)

convert matplotlib plots to plotly plots in ipython notebook

i just discovered plotly and my first thought was to have a matplotlib->plotly converter. this would allow people which have infrastructure in matplotlib use plotly with minimal effort.

for example, a project i work on (www.scikit-rf.org) has some canned plotting methods. it would be nice to re-use all of the existing functionality, but create a plotly plot instead of a matplotlib plot.

the simplest thing i could think of is to start with a line-plot and pull all the data (xy-data, labels, formating, etc) using matplotlib api, and then create the plotly plot.

i am thinking about this in respect to ipython notebooks.

any thoughts on this?

Wrong facebook link?

Hi,
Nice library!

I am going to 'like' you on facebook, however the facebook link is wrong and I can't access the plot.ly page on facebook neither.

UnicodeDecodeError

When I try to install plotly using pip in Windows 7 I get some sort of encoding error.

pip

I am using Anaconda with Python 3 as my main Python distribution. I had no problem installing plotly in Fedora with the same Anaconda configuration.

Import error : AttributeError: attribute '__doc__' of 'type' objects is not writable

On Python 3.2.3

In [1]: import plotly
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-c27a4132ad2e> in <module>()
----> 1 import plotly

/home/david/.virtualenv/glsl3/lib/python3.2/site-packages/plotly-1.1.4-py3.2.egg/plotly/__init__.py in <module>()
     29 from . version import __version__
     30 from . import graph_objs
---> 31 from . import plotly
     32 from . import tools
     33 from . import utils

/home/david/.virtualenv/glsl3/lib/python3.2/site-packages/plotly-1.1.4-py3.2.egg/plotly/plotly/__init__.py in <module>()
      8 
      9 """
---> 10 from .plotly import *
     11 
     12 __all__ = ["sign_in", "update_plot_options", "get_plot_options",

/home/david/.virtualenv/glsl3/lib/python3.2/site-packages/plotly-1.1.4-py3.2.egg/plotly/plotly/plotly.py in <module>()
    351 
    352 
--> 353 @utils.template_doc(**tools.get_config_file())
    354 class Stream:
    355     """ Interface to Plotly's real-time graphing API.

/home/david/.virtualenv/glsl3/lib/python3.2/site-packages/plotly-1.1.4-py3.2.egg/plotly/utils.py in _decorator(func)
    138     def _decorator(func):
    139         if func.__doc__ is not None:
--> 140             func.__doc__ = func.__doc__.format(**names)
    141         return func
    142     return _decorator

AttributeError: attribute '__doc__' of 'type' objects is not writable

Possible problems with fig['data'].update()

I just noticed while making a few modifications to section 0 of the Python API User Guide that

fig['data'].update(some_dict)

does not work as it once did e.g. In [31] in this old NB.

I made a more specific NB explaining this issue here.

In brief, the content of section 0 of the User Guide is inconsistent with the latest version of our Python API Library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.