# Choosing a Plotting Base to Build a Statistical Plotting Package

**URL:** <https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240>\
**Category:** Visualization\
**Created:** [June 2, 2021, 1:38am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240 "2021-06-02T01:38:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 2, 2021, 1:38am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/1 "2021-06-02T01:38:54Z")

</div>

If I wanted to build a package that adds more kinds of statistical plots to Julia, what would be the best plotting package to build it on top of? (e.g. Plots.jl, Makie, Gadfly, VegaLite) What advantages/disadvantages do they have? The most important things to me are being able to easily build new kinds of plots, as well as having users be able to customize them themselves.

(This wouldn’t really belong in StatsPlots or any kind of base plotting package, as the plots I’d like to add are fairly narrow in scope and meant to help with a specific kind of statistical analysis.)

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [June 2, 2021, 1:57am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/2 "2021-06-02T01:57:05Z")

</div>

IANAPPD (I am not a plotting package developer), but here are my 2 cents. Without more details from you, I would guess best to start with Plots.jl and its recipe system because it is the most widely used AFAIK.

That being said, I think the right choice specifically depends on what types of plots you want to work on (the quick and dirty type? the good looking (publication quality) type? Rasterized or vectorized? with LaTeX? Interactive or static? Geo-referenced (like maps and stuff)? 2D or 3D? and so on and so forth…) So if you can be specific on the plot types you want to target, then plotting-package developers here will be able to guide you better.

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [June 2, 2021, 5:37am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/3 "2021-06-02T05:37:02Z")

</div>

Some questions: Are you targeting the browser or print or …? How many points appear in your plots? How fast does it need to be?

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 2, 2021, 4:50pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/4 "2021-06-02T16:50:40Z")

</div>

In general I want good-looking, publication-quality graphics that can be printed. Speed is definitely very important, since some datasets might be very large. No geography/LaTeX are required; I don’t really care whether it outputs rasterized or vectorized (so long as I can choose the resolution for rasterized graphics). Static is good. 3d is a bonus but not very important. The thing I want is roughly some kind of equivalent of ggplot2 in R, which lets me pass objects to users that they can easily manipulate to get exactly what they want by customizing details.

The kinds of graphics I want to build are similar to the ones shown [here.](https://arviz-devs.github.io/arviz/examples/index.html).

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [June 2, 2021, 5:00pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/5 "2021-06-02T17:00:46Z")

</div>

I think you’re looking for something like [Algebra of Graphics](https://github.com/JuliaPlots/AlgebraOfGraphics.jl), which is being developed on top of Makie. @piever is the main developer, I believe and he can share more about the project.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [June 2, 2021, 5:04pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/6 "2021-06-02T17:04:58Z")

</div>

[StatsPlots.jl](https://github.com/JuliaPlots/StatsPlots.jl) may already have a lot of what you’re looking for, so it could be a good base.

I haven’t looked too much at the newer plotting packages, but I normally reach for Gadfly.

---

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [June 2, 2021, 5:08pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/7 "2021-06-02T17:08:31Z")

</div>

If you target Pluto.jl as a frontend, you can use the same approach like in [https://github.com/j-fu/PlutoVista.jl](https://github.com/j-fu/PlutoVista.jl) to wrap a JS plotting library.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 2, 2021, 7:22pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/8 "2021-06-02T19:22:09Z")

</div>

It looks like it has almost all the features I’d like to use in terms of basic objects, but from the examples, it doesn’t seem to be very easy to extend. For instance, let’s say I wanted to put together a scatter plot of a 2-d multivariate normal normal, using the covariance ellipse shown at the bottom to show a 95% prediction interval and a rug plot to show the marginals. In ggplot2 pseudocode, this would look kind of like:

```julia
ggplot(data, aes(x, y)) + geom_point() + geom_ellipse() + geom_rug()

```

I have no idea how I would get something this to work in StatsPlots. Gadfly seems easier to extend.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [June 2, 2021, 7:29pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/9 "2021-06-02T19:29:45Z")

</div>

AlgebraOfGraphics looks great! The only problem is it seems pretty new and very small, with only one or two people working on it. I don’t know how feature-complete or stable it is, or whether I can rely on it to stick around for the long-term – I’d probably feel a lot more comfortable using it if it was part of Makie’s base.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [June 5, 2021, 3:47pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/10 "2021-06-05T15:47:29Z")

</div>

Are you specifically looking to make a package for bayesian workflow plotting?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 5, 2021, 3:50pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/11 "2021-06-05T15:50:18Z")

</div>

> [@ParadaCarleton](#):
>
> I’d probably feel a lot more comfortable using it if it was part of Makie’s base.

Well, just for your info, it’s as much part of Makie’s base as possible 😉

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [June 5, 2021, 3:50pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/12 "2021-06-05T15:50:20Z")

</div>

You may want to join forces

[https://discourse.julialang.org/t/jsoc-2021-student-introduction-improve-different-aspects-of-mcmcchains-jl/](https://discourse.julialang.org/t/jsoc-2021-student-introduction-improve-different-aspects-of-mcmcchains-jl/)

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 5, 2021, 4:17pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/13 "2021-06-05T16:17:14Z")

</div>

A related question is, why do you need to make plots automatically anyways? Why not write functions that return objects that _can_ be plotted, like DataFrames, and leave the plotting up to the user?

---

<div class="post-metadata">

**Author:** ![paumar96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paumar96/32/37351_2.png) [@paumar96](https://discourse.julialang.org/u/paumar96)\
**Post date:** [June 5, 2021, 7:03pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/14 "2021-06-05T19:03:41Z")

</div>

Hi! As @EvoArt suggested, this summer I’ll be working as a JSoC student to improve the plotting functionality of MCMCChains package from Turing ecosystem. My idea for the JSoC project is similar to yours. Based on some state of the art packages for Bayesian data analysis such as RStan or ggmcmc from R or PyMC3 and Arviz from Python, the idea is to add elements to the currently used plots in MCMCChains.jl and modify plots defaults in order to improve and facilitate results visualization, presentation, and interpretation. To accomplish this, I’ll modify/extend/create recipes for the MCMCChains package (which uses StatsPlots.jl). If you’d like, we can discuss further about this!

I checked the link you posted about ArviZ example plots, and as mentioned above, StatsPlots.jl it’s a good start. For what you ask here, maybe [this](http://docs.juliaplots.org/latest/input_data/), [this](https://docs.juliaplots.org/latest/tutorial/#Using-Series-Recipes) and [this](https://docs.juliaplots.org/latest/layouts/#Advanced-Layouts) can help.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [June 5, 2021, 8:02pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/15 "2021-06-05T20:02:36Z")

</div>

FWIW I was initially put off plots/statsplots, as I don’t like the default look. But once you figure out how to customise stuff, that’s not an issue. Obviously, if you were building your own package on top, you could customise it to give the look you want.

Rather than geom\_A +geom\_B, plots uses A; B!. But seems like it wouldn’t be hard to make a macro to switch to the former style. Maybe I’m missing something though. I’m far from an expert.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [July 8, 2021, 11:59am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/16 "2021-07-08T11:59:13Z")

</div>

Did you choose a base in the end?  
Seems like a cool project.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [July 9, 2021, 12:14pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/17 "2021-07-09T12:14:41Z")

</div>

also, see here: [Rewriting MCMCChains with Makie.jl+AlgebraOfGraphics · Issue #306 · TuringLang/MCMCChains.jl · GitHub](https://github.com/TuringLang/MCMCChains.jl/issues/306)

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [July 11, 2021, 11:41pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/18 "2021-07-11T23:41:28Z")

</div>

I haven’t started work on it since I’ve been preoccupied with other projects, but I do think Makie+AlgebraOfGraphics is probably the way to go.

---

<div class="post-metadata">

**Author:** ![ymh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ymh/32/14650_2.png) [@ymh](https://discourse.julialang.org/u/ymh)\
**Post date:** [July 29, 2021, 7:37pm UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/19 "2021-07-29T19:37:39Z")

</div>

Hi, I’ve been thinking about doing something similar too (a package of convenience plotting functions for statistics, e.g. plotting residuals for regression with one command), and I had similarly been thinking about using AlgebraOfGraphics (though I’m a little worried that it might not be stable enough).

It will probably be a while before I can start on this, but if you are interested in casually working on this together (e.g. a couple of hours every week or every other week), I’d be interested in doing that.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [August 4, 2021, 12:39am UTC](https://discourse.julialang.org/t/choosing-a-plotting-base-to-build-a-statistical-plotting-package/62240/20 "2021-08-04T00:39:08Z")

</div>

If you’re interested, I strongly recommend checking out the #Turing and #probprog channels in the Slack and asking about Turkie.jl, which is similar to what I had in mind.
