Package: altair-recipes
A collection of ready-made statistical graphics for vega.vegais a statistical graphics system for the web, meaning the plots are displayed in a browser. As an added bonus, it adds interactions, again through web technologies: select data point, reveal information on hover etc. Interaction and the web are clearly the future of statistical graphics. Even the successor to the famousggplotfor R,ggvisis based onvega.altairis a python package that producesvegagraphics. Likevega, it adopts an approach to describing statistical graphics known asgrammar of graphicswhich underlies other well known packages such asggplotfor R. It represents a extremely useful compromise of power and flexibility. Its elements are data, marks (points, lines), encodings (relations between data and marks), scales etc.Sometimes we want to skip all of that and just produce a boxplot (or heatmap or histogram, the argument is the same) by calling:boxplot(data.iris(), columns="petalLength", group_by="species")because:It’s a well known type of statistical graphics that everyone can recognize and understand on the fly.Creativity is nice, in statistical graphics as in many other endeavors, but dangerous: there are morebad chartsout there than good ones. Thegrammar of graphicsis no insurance.While it’s simple to put together a boxplot inaltair, it isn’t trivial: there are rectangles, vertical lines, horizontal lines (whiskers), points (outliers). Each element is related to a different statistics of the data. It’s about30 lines of codeand, unless you run them, it’s hard to tell you are looking at a boxplot.One doesn’t always need the control that the grammar of graphics affords. There are times when I need to see a boxplot as quick as possible. Others, for instance preparing a publication, when I need to control every detail.The boxplot is not the only example. The scatterplot, the quantile-quantile plot, the heatmap are important idioms that are battle tested in data analysis practice. They deserve their own abstraction. Other packages offering an abstraction above the grammar level are:seabornand the graphical subset ofpandas, for example, both provide high level statistical graphics primitives (higher than the grammar of graphics) and they are quite successful (but not web-based).ggplot, even if named after the Grammar of Graphics, slipped in some more complex charts, pretending they are elements of the grammar, such asgeom_boxplot, because sometimes even R developers are lazy. But a boxplot is not ageomor mark. It’s a combination of several ones, certain statistics and so on. I suspect the authors ofaltairknow better than mixing the two levels.altair_recipesaims to fill this space abovealtairwhile making full use of its features. It provides a growing list of “classic” statistical graphics without going down to the grammar level. At the same time it is hoped that, over time, it can become  a repository of examples and model best practices foraltair, a computable form of itsgallery.There isone more thing. It’s nice to have all these famous chart types available at a stroke of the keyboard, but we still have to decide which type of graphics to use and, in certain cases, the association between variables in the data and channels in the graphics (what becomes coordinate, what becomes color etc.). It still is work and things can still go wrong, sometimes in subtle ways. Enterautoplot.autoplotinspects the data, selects a suitable graphics and generates it. While no claim is made that the result is optimal, it will make reasonable choices and avoid common pitfalls, likeoverlapping pointsin scatterplots. While there are interestingresearch effortsaimed at characterizing the optimal graphics for a given data set, their goal is more ambitious than just selecting from a repertoire of pre-defined graphics types and they are fairly complex. Therefore, at this timeautoplotis based on a set of reasonable heuristics derived from decades of experience such as:use stripplot and scatterplot to display continuous data, barcharts for discrete datause opacity to counter mark overlap, but not with discrete color mapsswitch to summaries (count and averages) when the amount of overlap is too highuse facets for discrete dataautoplotis work in progress and perhaps will always be and feedback is most welcome. A large number of charts generated with it is available at the end of theExamplespage and should give a good idea of what it does. In particular, in this first iteration we do not make any attempt to detect if a dataset represents a function or a relation, hence scatterplots are preferred over line plots. Moreover there is no special support for evenly spaced data, such as a time series.FeaturesFree software: BSD license.Fullydocumented.Highly consistent API enforced withautosigNear 100% regression test coverage.Support for dataframe and vector inputsSupport for both wide and long dataframe formats.Data can be provided as a dataframe or as a URL pointing to a csv or json file.All charts produced are validaltaircharts, can be modified, combined, saved, served, embedded exactly as one.Chart typesautocorrelationbarchartboxplotheatmaphistogram, in a simple and multi-variable versionqqplotscatterplot in the simple and all-vs-all versionssmoother, smoothing line with IRQ range shadingstripplotSeeExamples.