7 ms·
By far and away the best python plotting library is plotnine, a python clone of ggplot maintained by Hassan Kibirige from Uganda. By the estimation of one este
by nmca 3y ago
By far and away the best python plotting library is plotnine, a python clone of ggplot maintained by Hassan Kibirige from Uganda.
By the estimation of one esteemed colleague "it obviously pays back the time investment in less than a couple of days". I agree.
- eyegor 3y agoI see the potential long term but that api is unintuitive at best. It almost seems obstructively terse. (ggplot(mtcars, aes("wt", "mpg", color="factor(gear)")) + geom_point() + stat_smooth(method="lm") + facet_wrap("~gear")) From https://github.com/has2k1/plotnine https://github.com/has2k1/plotnine, their front page examples. I get that it's ripping off the ggplot api, but why would they not alias "aes" to something more meaningful? It stands for "aesthetic mapping". My problem with all the popular plotting libraries in python is they seem designed for researchers slapping together a paper and produce code that's awful to maintain.
- blt 3y agodo you feel that about Seaborn even? it can be too "on the rails" for some applications, but if the rails meet your needs, the plotting calls look clean and maintainable to me.
- fn-mote 3y ago> [...] why would they not alias "aes" to something more meaningful? This criticism doesn't do anything for me. Is an alias for a 3 letter function name really going to improve readability / usability? It's the same API. Take it up with Hadley Wickham. I think having one interface that is the same (ok, "mostly the same") for R and Python is a blessing for people who work with both. I don't graph with Python much, but every time I have to plot in Python I sigh and ask myself if it would be easier to just import the data into R.
- coldtea 3y ago>Is an alias for a 3 letter function name really going to improve readability / usability? In this case, absolutely. Plus it shows the attention to detail, or lack thereof, across the whole API.
- lifthrasiir 3y agoAs who hadn't seriously used any plotting library, some of my questions: - Why isn't the first term `ggplot(mtcars, "wt", "mpg", color="factor(gear)")` instead? It seems that the second argument always has to be a `plotnine.mapping.aes(...)` call or a saved `aes` value. It is not really hard to distinguish `ggplot(data, saved_aes)` from `ggplot(data, "x-col", "y-col", ...)`. The only issue might be the third `environment` argument, but that can go elsewhere (see below). - What's up with that operator overloading? Is `+=` even supported? It seems that the original R version had the same syntax, but Python's statement-based syntax makes it annoying to use. Maybe any "additions" should have been moved into `ggplot` arguments by default: `ggplot(mtcars, "wt", "mpg", geom_point(), stat_smooth(...), facet_wrap(...), color="...")`. - Many "addable" values have common repeating prefixes (`geom_` etc). Doesn't sound like a good API design at all, especially in Python. Probably there should be a `geom` module and so on that are exposed via `from plotnine import *` instead, so that `geom.point()` would work for example. - Formulae as strings are fine to have, but it somehow has multiple "stages" where they can be evaluated (`after_stat` etc). Such feature would be necessary from time to time, but the concept itself doesn't seem to be not well polished.
- nmca 3y agobest by far != perfect
- unnah 3y agoAs someone who makes plots every now and then with breaks of several months in between, I have found the ggplot syntax surprisingly intuitive and easy to remember even after a long break. Importantly, the basic syntax can be used to compose quite complicated graphs, although it does have its limits. It's also quite nice to be able to use the same interface in both R and Python, although it is obvious that it was originally developed for R.