Skip to content
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

Support with statements to build clean plots #58

Open
elben10 opened this issue Dec 14, 2018 · 3 comments
Open

Support with statements to build clean plots #58

elben10 opened this issue Dec 14, 2018 · 3 comments

Comments

@elben10
Copy link

elben10 commented Dec 14, 2018

THIS IS FEATURE REQUEST

Environment:

  • Chartify version(s): '2.3.5'
  • Operating System(s): 'win32'
  • Python version(s): 3.7 (Conda)

I suggest to support the with statement in the following way:

import chartify
import pandas

class Chart(chartify.Chart):
    def __enter__(self):
        return self
    def __exit__(self, type, value, traceback):
        self.show()

df = pandas.DataFrame({'x': [1, 2, 3], 'y': [1, 2, 3]})

with Chart() as ch:
    ch.plot.line(df, 'x', 'y')
    ch.set_title("Example")

This would allow a very simple and clean way of structuring one's plots.

@elben10
Copy link
Author

elben10 commented Dec 14, 2018

Or maybe this to run plots out of the box in google colab.

class Chart(chartify.Chart):
    def __enter__(self):
        import bokeh
        bokeh.io.output_notebook()
        return self
    def __exit__(self, type, value, traceback):
        self.show()

@vadymhimself
Copy link

@elben10 did you manage to get an HTML-rendered output for Colab? I can only get PNG output, and even that requires installing chromedriver on the colab's virtual machine.

@elben10
Copy link
Author

elben10 commented Jun 18, 2019

Try to take a look at this notebook. https://colab.research.google.com/notebooks/charts.ipynb#scrollTo=nv8P3UYm6SiQ

You need to use output_notebook function within the cell.

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

2 participants