Marsilea-viz / marsilea

Declarative creation of composable visualization for Python (Complex heatmap, Upset plot, Oncoprint and more~)
https://marsilea.rtfd.io/
MIT License
163 stars 6 forks source link

Sizing and aligning canvases in rows/columns #49

Open jpintar opened 1 week ago

jpintar commented 1 week ago

Problem/New Plotter

When joining two main canvases in a row or column, the specified size of the second canvas appears to be ignored along one dimension.

For example, if we have

data1 = np.random.randn(5, 5)
data2 = np.random.randn(3, 10)

m1 = ma.Heatmap(data1, width=5, height=5)
m2 = ma.Heatmap(data2, width=10, height=3)

then (m1 + 1 + m2).render() sets the height of the m2 plot to equal the height of m1. Likewise (m1 / 1 / m2).render() sets the width of the m2 plot to equal the width of m1.

Is it possible to maintain the specified dimensions of both the plots (and perhaps also specify how they should be aligned if they are not the same size)?

Proposed solution

No response

Mr-Milk commented 1 week ago

Sorry that this is not clearly stated in the documentation, it's by design that the side of m2 will be aligned to the size of its append side of m1. I have thought about making it optional to maintain the layout, but this may potentially introduce complicity in the layout algorithm since we have dynamics sizing for plotters that render text. It would be great if you could provide a use case on why you want to maintain the layout and why the current auto-align doesn't work for you.

jpintar commented 1 week ago

My use case is part of the one I described in this comment on issue #48. I have scRNA-seq data from multiple experimental conditions that would best be arranged in rows or columns, but each data set has a different number of rows (corresponding to Leiden clusters). To facilitate comparison, it would be ideal to be able to maintain constant row height across the plots.