4 ms·
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
by minimaxir 8y ago
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.
- jdonaldson 8y agoPython's community for DS/Viz is great, but imho it doesn't have creative savants like Hadley Wickham or Michael Bostock.
- ObscureMind 8y agoCheck plotnine, which is a decent reimplementation of ggplot2 in python: https://plotnine.readthedocs.io/en/latest/ https://plotnine.readthedocs.io/en/latest/
- ExcaliburZero 8y agoPlotnine 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..
- ObscureMind 8y agoThe authors also provide a reimplementation of dplyr in Python that integrates well with plotnine: https://github.com/has2k1/plydata https://github.com/has2k1/plydata
- minimaxir 8y agoHuh, 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 https://github.com/has2k1/plotnine I'll give it a shot! :)
- kugestu 8y agoI find myself often using the R ggplot2 documentation for using plotnine - it is such a decent port!
- dnhz 8y agoHow do you transfer data from Python to R? I like the look of ggplot2, but most of my data I keep as pickle files.
- minimaxir 8y agoExporting 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.
- dnhz 8y ago>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.
- cwyers 8y agoFeather, 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.
- RyEgswuCsn 8y agoIf 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-jupyter-notebook-jared-stufft/ https://www.linkedin.com/pulse/interfacing-r-from-python-3-j...
- makmanalp 8y agoI 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). https://altair-viz.github.io/gallery/index.html https://altair-viz.github.io/gallery/index.html
- j88439h84 8y agoPlotnine is the good port of ggplot.