Skip to content

convert matplotlib plots to plotly plots in ipython notebook #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arsenovic opened this issue Jan 11, 2014 · 8 comments
Closed

convert matplotlib plots to plotly plots in ipython notebook #3

arsenovic opened this issue Jan 11, 2014 · 8 comments

Comments

@arsenovic
Copy link
Contributor

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?

@arsenovic
Copy link
Contributor Author

http://nbviewer.ipython.org/gist/arsenovic/8375182

@msund
Copy link
Contributor

msund commented Jan 24, 2014

Hey Alex, thanks for checking out Plotly. We've talked about this idea before. What other plotting methods are you working on and do you all use? If you want to submit a pull request, we'd welcome any and all help and love to work with you.

That's a very cool NB.

@arsenovic
Copy link
Contributor Author

@mattsundquist , here is an example of common plots for scikit-rf comparing matplotlib and plotly.

http://nbviewer.ipython.org/gist/arsenovic/8714896#

obviously this is just a proof of concept. it would be nice to get some feedback/ideas from the ipython/matplotlib team ( @ellisonbg @fperez @mdboom ).. i think it would be great to have a more comprehensive converter, perhaps even a note-book wide output via config option, c.InlineBackend.figure_format or rcParams or something. . .?

@ellisonbg
Copy link

This is fantastic! The way we are recommending that third party projects handle this is to define an HTML formatter for maplotlib.Figure objects. Once you do that, if the users is running with %pylab inline or %matplotlib inline it will "just work" = the plots will just show up when a user calls the various matplotlib plot functions - no explicit call needed to display. mpld3 is already doing this exactly. Here is there code for it:

https://github.com/jakevdp/mpld3/blob/master/mpld3/display.py#L103

@msund
Copy link
Contributor

msund commented Apr 2, 2014

Thanks for the idea and inspiration @arsenovic and all your help and support @ellisonbg. This project is ongoing, but definitely up and running: https://pypi.python.org/pypi/matplotlylib.

For a NB, check out some of the @theengineear's delightful plots:

http://nbviewer.ipython.org/github/mpld3/matplotlylib/blob/master/notebooks/Plotly%20and%20mpld3.ipynb.

@msund msund closed this as completed Apr 2, 2014
@arsenovic
Copy link
Contributor Author

very impressive.

@ellisonbg
Copy link

Awesome!

On Wed, Apr 2, 2014 at 12:51 AM, msund [email protected] wrote:

Closed #3 #3.

Reply to this email directly or view it on GitHubhttps://github.com//issues/3
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
[email protected] and [email protected]

@chriddyp
Copy link
Member

This is now officially incorporated in the plotly package now (Version 1.0.x). Thanks again for the suggestions!

Check out the matplotlylib chapter in our plotly user guide here: http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s6_matplotlylib/s6_matplotlylib.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants