Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support transposing layouts? #909

Closed
jbednar opened this issue Oct 6, 2016 · 4 comments
Closed

Support transposing layouts? #909

jbednar opened this issue Oct 6, 2016 · 4 comments
Milestone

Comments

@jbednar
Copy link
Member

jbednar commented Oct 6, 2016

Right now, layouts are filled with plots in row order, i.e. left to right and then top to bottom:

image

Sometimes it makes much more sense to order the plots in column order, i.e. top to bottom and then left to right, as in this case, to align related plots. It is possible to reorder the plots in the layout manually:

def lay_out_in_columns(_list, cols, spacer=hv.Empty()):
    """Given a list, reorder it into the number of columns specified, filling missing items with the given spacer."""
    rows = int(np.ceil(len(_list)*1.0/cols))
    padded = _list + [spacer] * (rows*cols-len(_list))
    return list(np.array(padded).reshape(cols,rows).T.flat)

image

This works, but it's awkward, and if subfigure labels weren't suppressed here they would still be in row order, which would be confusing. So it would be great if there were a plot option to transpose the layout after it has been assigned subfigure labels.

@basnijholt
Copy link
Contributor

Seems related to #130.

@jlstevens
Copy link
Contributor

jlstevens commented Oct 10, 2016

@basnijholt Thanks for linking to issue #130!

For GridSpace, using the reindex method worked as that object has its own dimensions. The difference with Layouts is that they can contain heterogeneous mixtures of different element types so I don't believe the same approach will work here.

Certainly a worthwhile comparison to make and something we will want to document better.

@jbednar
Copy link
Member Author

jbednar commented Oct 10, 2016

The layout is essentially just an ordered list, and thus doesn't have any inherent dimensions to transpose directly. It's only when it's laid out for display that it gets put into a row, column format. So in the code above I'm reordering this list so that the eventual result is in column order, but really this needs to be something that the layout engine decides as it puts into a columnar shape.

@philippjfr
Copy link
Member

The transpose plot option has now been added for all backends, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants