Remix.run Logo
piqufoh 3 hours ago

`from plotnine import *`

... I love the idea of a new python plotting library, but why is this anti-pattern so common with plotting libs?

jeroenjanssens 3 hours ago | parent | next [-]

While it’s generally considered to be bad practice to import everything into the global namespace, I think it’s fine to do this in an ad-hoc environment such as a notebook as it makes using the many functions plotnine provides more convenient. An additional advantage is that the resulting code more closely resembles the original ggplot2 code. Alternatively, it’s quite common to `import plotnine as p9` and prefix every function with `p9`.

Disclaimer: I made the plotnine homepage and cheatsheet.

jamessb 3 hours ago | parent | prev | next [-]

> a new python plotting library

Whilst it's still not yet at 1.0.0, it's not that new: the first (0.1.0) release was in 2017: https://pypi.org/project/plotnine/#history

LoganDark 3 hours ago | parent [-]

matplotlib's first release was in 2003, making it more than twice as old.

teruakohatu 3 hours ago | parent | prev | next [-]

Because most of the time this will be used is not part of a software development project but rather producing publication plots in a script or plots in a notebook. Not what you would want to do when incorporating it into a web app.

globular-toast 3 hours ago | parent | prev [-]

Because it's aimed at data scientists who would rather be using R...