Closed
Description
Hi ponnhide!
Big fan of your library, very happy that I came across it. I noticed that sometimes labels of Bricks are not quite aligned when the axes of subplots are aligned, but the bounding box of one of the subplots is larger. Here's a simple example:
import numpy as np
import pandas as pd
import plotnine as p9
import patchworklib as pw
np.random.seed(1)
data_a = np.random.normal(loc=1, scale=1, size=1000)
data_b = np.random.normal(loc=1, scale=1, size=1000)
data_c = np.random.normal(loc=1e8, scale=1, size=1000)
df = pd.DataFrame({"data_a": data_a, "data_b": data_b, "data_c": data_c})
plot0 = (p9.ggplot() + p9.geom_point(data=df, mapping=p9.aes(x='data_a', y='data_b')))
plot1 = (p9.ggplot() + p9.geom_point(data=df, mapping=p9.aes(x='data_a', y='data_c')))
plots = [plot0, plot1]
n_plots = len(plots)
m = (2, 2)
bricks = [pw.load_ggplot(p, figsize=m) for p in plots]
letters = ['A', 'B']
for i in range(n_plots):
bricks[i].set_index(letters[i])
layout = pw.stack(bricks, operator="/")
I was wondering if there was a way to align the labels of the subplots in this case, i.e. align the A and B labels on the left?
As a workaround, I tried to use layout.get_outer_corner()[0]
or layout.get_outer_corner()[0] - bricks[i].get_outer_corner()[0]
to adjust the x of set_index(x=...)
, but was not successful. Any tips how that could be done?
Thanks very much!
Metadata
Metadata
Assignees
Labels
No labels