Re:Python Data Visualization 2018: Why So Many Libraries?
by minimaxir on Friday November 16, 2018 @01:23PM
(#18470719)
I'm pretty good at Python and do most of my work in it nowadays, but if I need to make a data visualization, I still go to R just for ggplot2. Nothing currently in Python compares (not even the "ggplot2 port"), and it takes an order of magnitude longer to make a comparable viz.
[ Parent
| on HN ]
Re:Python Data Visualization 2018: Why So Many Libraries?
by makmanalp on Friday November 16, 2018 @04:47PM
(#18472235)
I heartily recommend altair, which is maturing nicely - while the API is not a clone of ggplot, it takes the same grammar-of-graphics idea and applies it to interactive graphics.
It's 5-6 lines of code per chart for most examples here, with a few more lines for interaction (e.g. selection and linked brushing across graphs).
Re:Python Data Visualization 2018: Why So Many Libraries?
by ObscureMind on Friday November 16, 2018 @02:56PM
(#18471503)
Check plotnine, which is a decent reimplementation of ggplot2 in python:
https://plotnine.readthedocs.io/en/latest/
Re:Python Data Visualization 2018: Why So Many Libraries?
by kugestu on Friday November 16, 2018 @06:08PM
(#18472697)
I find myself often using the R ggplot2 documentation for using plotnine - it is such a decent port!
Re:Python Data Visualization 2018: Why So Many Libraries?
by minimaxir on Friday November 16, 2018 @03:20PM
(#18471656)
Huh, when I was looking into Python options I had thought plotnine was dead, but looking at the GitHub that's not the case: https://github.com/has2k1/plotnine
I'll give it a shot! :)
Re:Python Data Visualization 2018: Why So Many Libraries?
by ExcaliburZero on Friday November 16, 2018 @03:03PM
(#18471549)
Plotnine is quite nice. Its api is very similar to R's ggplot so it gives you the same level of expressiveness and flexibility while being able to stay the Python ecosystem to use numpy, pandas, etc..
Re:Python Data Visualization 2018: Why So Many Libraries?
by ObscureMind on Friday November 16, 2018 @03:06PM
(#18471568)
The authors also provide a reimplementation of dplyr in Python that integrates well with plotnine:
https://github.com/has2k1/plydata
Re:Python Data Visualization 2018: Why So Many Libraries?
by jdonaldson on Friday November 16, 2018 @01:44PM
(#18470894)
Python's community for DS/Viz is great, but imho it doesn't have creative savants like Hadley Wickham or Michael Bostock.
Re:Python Data Visualization 2018: Why So Many Libraries?
by RyEgswuCsn on Friday November 16, 2018 @04:44PM
(#18472215)
If you are using Python with Jupyter notebooks, another way to create graphs with ggplot2 is to interface directly with an R session using the rpy2 package. A nice tutorial can be found here: https://www.linkedin.com/pulse/interfacing-r-from-python-3-j...
Re:Python Data Visualization 2018: Why So Many Libraries?
by dnhz on Friday November 16, 2018 @03:31PM
(#18471729)
How do you transfer data from Python to R? I like the look of ggplot2, but most of my data I keep as pickle files.
Re:Python Data Visualization 2018: Why So Many Libraries?
by cwyers on Friday November 16, 2018 @05:52PM
(#18472598)
Feather, based on the Apache Arrow format, is a lot faster than CSVs, and there's good support in both R and Python for it, maintained by Hadley Wickham (who has developed Almost Ever R Package You've Heard Of) and Wes McKinney (who is the BDFL of pandas) respectively. It also involves less inferring of data types using heuristics.
Re:Python Data Visualization 2018: Why So Many Libraries?
by minimaxir on Friday November 16, 2018 @03:37PM
(#18471762)
Exporting as a CSV (e.g. pandas's to_csv) works fine, since R/ggplot2 expects tabular data.
You probably shouldn't be keeping data as pickles, for both compatibility and security reasons.
Re:Python Data Visualization 2018: Why So Many Libraries?
by dnhz on Sunday November 18, 2018 @08:36PM
(#18483602)
>You probably shouldn't be keeping data as pickles, for both compatibility and security reasons
It's science research. My own simulation code and data. Some of it is hdf5, but pickle files are pretty convenient. Workflow is mainly turning data into plots. Heh, I thought I was doing alright since I'm not using textfiles.