chartify
chartify copied to clipboard
Support with statements to build clean plots
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.
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()
@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.
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.