Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

"grid" histogram placement #21

Closed
imandr opened this issue Jun 13, 2018 · 3 comments
Closed

"grid" histogram placement #21

imandr opened this issue Jun 13, 2018 · 3 comments
Labels
feature-request New functionality is desired

Comments

@imandr
Copy link

imandr commented Jun 13, 2018

In addition to beside() and below(), it would be good to have grid() method to place a list of histograms in grid fashion, e.g:

grid(5, [hist1.step(), hist2.step(), ...]) - place histograms in Nx5 grid (N rows by 5 histograms)
hist.grid(5, "param") - produce views with constant "param" and place them into Nx5 grid

@jpivarski jpivarski added the feature-request New functionality is desired label Jun 13, 2018
@jpivarski
Copy link
Member

Right. Thanks for the name! (PAW had "zones" and ROOT has "pads", neither of which is an intuitive name for me. "Grid" makes a lot of sense.)

I can do the first of these, but not the second. grid can be a standalone function that works like the beside and below standalone functions. But the methods that split data depend on functionality in Vega-Lite.

Notice how Vega-Lite renders histograms beside each other under a global axis title (e.g. "centrality bins") and labels (e.g. "0‒10%", "10‒30%", "30‒50%"). Each of those plots is, graphically, like a really big bin. If the values were spread in a grid like left-to-right, top-to-bottom reading order, then they couldn't be presented under a single axis. Graphically, one would need to put a legend in each re-stating the axis title ("centrality") and its current value. Physicists do this, it's a desired plot type, but not one with a convenience function in Vega-Lite.

So while the first case is something I can do, the second is a feature request for Vega-Lite. (The first makes it possible to manually build the second by constructing legends and such.)

jpivarski added a commit that referenced this issue Jun 18, 2018
@jpivarski
Copy link
Member

Now we have grid:

>>> import numpy
>>> from histbook import *
>>> h = Hist(bin("x", 100, -5, 5), fill=numpy.random.normal(0, 1, 1000000))
>>> plot = h.step()
>>> grid(2, plot, plot, plot).vegascope()

vegascope

@jpivarski
Copy link
Member

Somehow I missed checking this earlier, but overlay, beside, below, and grid are supposed to be composable (where logically possible). That's fixed now.

>>> import numpy
>>> from histbook import *
>>> h = Hist(bin("x", 10, -5, 5), fill=numpy.random.normal(0, 1, 1000000))
>>> below(h.step(), beside(h.line(), overlay(h.area(), h.marker()))).vegascope()

vegascope 1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New functionality is desired
Projects
None yet
Development

No branches or pull requests

2 participants