ggplot for Haskell (was Re: [diagrams] Using charts in blogliteratelyd)

Hi Daniel, Thanks for your comprehensive reply.
I don't feel like I understand the design space enough to start such a project, but I'd contribute if someone gets it started, or I'd discuss it more first.
I am pretty sure I don't understand the design space either.
Can you say a bit about what a library needs to be "like ggplot", rather than like other graphing libraries? Is it mostly about separating the graph description from the data, and composable abstractions for the graph to support things like faceting?
I think we can already do faceting e.g. https://idontgetoutmuch.files.wordpress.com/2014/06/044408c77f048f73.png?w=1... I had a quick look at http://byrneslab.net/classes/biol607/readings/wickham_layered-grammar.pdf I may have misunderstood but I think it has a limited scope and calling it a grammar of graphics suggests in can do more than it actually can. That is not to be critical: it is very powerful just not as powerful as the name suggests. What I wanted to draw was something like this: http://www.helsinki.fi/varieng/series/volumes/07/siirtola_et_al/figures/sfig... but that uses a package called Beanplot (http://www.jstatsoft.org/v28/c01/paper) not ggplot. I actually managed to sketch something that was close to what I wanted using diagrams (not chart). http://i.imgur.com/TeyloXA.png So I feel we are quite close to something that is more powerful than ggplot. But my attempts both at the above and at facets are not very flexible / re-usable. However, I feel I am re-inventing the charts wheel. What I feel I need is access to the chart components not to just be able to create a chart. Maybe we should talk directly to the author of charts. I don't think it is possible to create the above example using charts. A further thing one can't do with charts is annotations. I believe one can do this in ggplot. I think as you suggest, we need composable abstractions. For my example, I created a grid and overlaid the histograms on top of it. I'd like to overlay axes on it as well and a legend.
I've used Chart (in Haskell) and ggplot a little, but mostly have experience with Python using matplotlib & pandas. The last time I looked at making an R / pandas environment in Haskell, I got bogged down in picking a dataframe type. tables[1] & Frames[2] both look relevant.
I've used frames and pandas a bit. As far as I understand it they
carry around a description of the data along with the data; ggplot can
then make use of this. I don't see it as essential and I wouldn't want
"ggplot in Haskell" to depend on either tables or frames
Maybe we could start "ggplot in Haskell" by somehow generalizing my
feeble examples?
Dominic Steinitz
dominic@steinitz.org
http://idontgetoutmuch.wordpress.com
On 17 Feb 2015, at 00:02, Daniel Bergey
On 2015-02-16 at 09:15, idontgetoutmuch
wrote: 2. Why does haskell-chart load fonts but diagrams itself doesn't? Does diagrams generate fonts on the fly somehow?
The answer depends on which Diagrams Backend you are using. Backends which output raster images load the fonts they use. Vector output formats may get away refering to the font name, and expecting the viewer to load the font. Some vector backends can access font metrics to position (eg, center) text.
I may be wrong about some of the following table:
| Backend | Embed Font / bitmap | Font Metrics | |------------+--------------------------+--------------| | Cairo | depends on output format | Y | | SVG | N | partial | | Rasterific | Y | partial | | Canvas | N | partial |
I believe Chart loads fonts to provide better text positioning than the Diagrams Backends currently support. I think there's some low-hanging fruit, here, notably https://github.com/diagrams/diagrams-rasterific/issues/21 now that Rasterific has the needed feature.
3. Has anyone shown any interest in writing something like ggplot using diagrams? This would be a fantastic tool but wouldn't be a trivial undertaking.
Quite a few people have expressed interest in *using* such a library. I haven't heard anyone say they have time to write it, but maybe between us we do.
I don't feel like I understand the design space enough to start such a project, but I'd contribute if someone gets it started, or I'd discuss it more first.
Can you say a bit about what a library needs to be "like ggplot", rather than like other graphing libraries? Is it mostly about separating the graph description from the data, and composable abstractions for the graph to support things like faceting?
I've used Chart (in Haskell) and ggplot a little, but mostly have experience with Python using matplotlib & pandas. The last time I looked at making an R / pandas environment in Haskell, I got bogged down in picking a dataframe type. tables[1] & Frames[2] both look relevant.
cheers, bergey
Footnotes: [1] http://hackage.haskell.org/package/tables
participants (1)
-
Dominic Steinitz