scikit-bio
scikit-bio copied to clipboard
Refactoring skbio's plotting feature
The current scikit-bio codebase has several plotting functions, such as heat map for DistanceMatrix
and scatter plot for OrdinationResults
. However, the way the plots are delivered may be outdated.
Take DistanceMatrix.plot
for example. It imports matplotlib and creates a figure from within the method, rather than using an existing matplotlib.Axes
instance if provided. This makes the figure not reusable. The heavy dependency IPython
is only for displaying matplotlib plots in the interactive notebook in SVG or PNG format. This is not necessary. There are more convenient approaches to display (fig.show()
, if needed) or save a figure (fig.savefig('file.png')
). It is not necessary to bind skbio to a live Jupyter interface.
A few examples of how other packages handle plots: Scikit-learn (link) and Biotite (link) can accept a user-provided matplotlib.Axes
instance. This adds flexibility of customization and integration. Pandas is most flexible. It allows an arbitrary plotting backend, which by default is matplotlib, but it can also be any compatible module such as plotly (and the output plot becomes interactive).
Proposal: 1) Remove IPython as a dependency. 2) Let plot
methods take an ax
parameter. 3) Currently scikit-bio can stick to matplotlib; it is not a priority to add support for arbitrary backends (although it might be a plus). @mortonjt @wasade .