chartpy creates a simple easy to use API to plot in a number of great Python chart libraries like plotly (via cufflinks), bokeh and matplotlib, with a unified interface. You simply need to change a single keyword to change which chart engine to use (see below), rather than having to learn the low level details of each library. I've also created new stylesheets and formating to ensure that the default matplotlib styling looks more modern using Open Sans font.
Contributors for the project are very much welcome, sell below!
chart = Chart(df=df, chart_type='line', style=style) # we now plot using multiple plotting libraries, with the same dataframe chart.plot(engine='matplotlib') chart.plot(engine='bokeh') chart.plot(engine='plotly')
I had previously written the open source PyThalesians financial library. This new chartpy library has some similar functionality to the chart part of that library. However, I've totally rewritten the API to make it much cleaner and easier to use. It is also now a fully standalone package, so it'll be easier to use for both non-financial and financial applications. It also has many more features including subplots and much more.
At present chartpy supports several types of plots
There is also very early support for line charts generated by vispy, which allows for GPU accelerated plotting in Python. However, at present the wrapper doesn't yet support plotting of dates (these are ignored when plotting).
There is a big speed improvement in using the VisPy wrapper if you are plotting many millions of points (with a small number of points matplotlib seems quicker). Installation instructions for VisPy are here. By default, chartpy will install the latest release version, but you find it necessary to use the most up to date development version of VisPy
Other points to note
Doing plots in multiple libraries by simply changing a keyword, from the Jupyter notebook.
Create subplots with minimal extra coding (see examples/subplot_examples.py)
Do surface plots (plotly only at present - see examples/surface_examples.py)
Do bar horizontal plots (matplotlib and plotly - see examples/chart_demo.py)
Create heatmaps (matplotlib and plotly - see examples/chart_demo.py)
Create HTML webpages (using Canvas class - see examples/canvas_demo.py) - using mixture of plots (plotly, bokeh & matplotlib), tables and text, with just a few lines of Python! The HTML file can then be uploaded to a webserver for display (or sent around by e-mail etc)
My chartpy stylesheet for matplotlib uses the free Open Sans font. For it to display properly you need to install Open Sans font on your computer
You can install the library using the below (latest version). After installation:
pip install git+https://github.com/cuemacro/chartpy.git
You can also install chartpy from PyPI (but this will usually be a slightly older version)
pip install chartpy
Note that chartpy now supports Plotly 4, because Cufflinks 0.17 now works with Plotly 4!
pip install cufflinks==0.17 plotly==4.2.1
There are many good charting libraries. However, they all have different APIs. It took me a lot of time to learn a new API, for each new plotting library I wanted to use. I ended up writing chartpy to abstract away all this complexity, so I could concentrate on analysing data, rather than getting caught up in complex API visualisation calls. Rather than having to totally edit my code each time, a single keyword is enough to switch between for example plotly and matplotlib.
I've also tried to design the library so that adding a new plotting engine is fairly straightforward (extend EngineTemplate and edit the get_engine method in Chart), so it's basically future proof for whatever new chart libraries come along, with relatively small changes to your code base.
chartpy also has interactive dashboards based on Plotly's Dash package, but with a lot less of the boilerplate code
which Dash uses. Users extend
LayoutCanvas to create their own Dash layouts and
SketchComponents can be used
to quickly create Dash components/HTML components, with relatively few lines of code.
Hence, it's a lot quicker to create Dash based dashboards in chartpy! In the future, we want to also support other Python dashboards like H2O Wave.
You'll need to install Dash as an extra to use them as they aren't part of the default installation, which we can see below (Linux at top, Windows on bottom):
pip install cufflinks==0.17.3 plotly==4.14.3 kaleido dash==1.20.0 \ dash-html-components==1.1.3 dash-core-components==1.16.0 dash-table==4.11.3 \ jupyter-dash==0.4.0 chart_studio==1.1.0 pip install cufflinks==0.17.3 plotly==4.14.3 kaleido dash==1.20.0 ^ dash-html-components==1.1.3 dash-core-components==1.16.0 dash-table==4.11.3 ^ jupyter-dash==0.4.0 chart_studio==1.1.0
Contributors are always welcome for finmarketpy, findatapy and chartpy. If you'd like to contribute, have a look at Planned Features for areas we're looking for help on. Or if you have any ideas for improvements to the libriares please let us know too!
In chartpy/examples you will find several demos
End of note