brokenaxes
brokenaxes copied to clipboard
tight_layout() support?
Cool package! Are you planning to add fig.tight_layout()
support?
I get an error message: warnings.warn("This figure includes Axes that are not compatible "
and the lines which break the axes get shifted (outside of the axis) when trying to use tight_layout()
I like that idea. I'll look into it
Can you clarify what the desired behavior would be? Would the gaps between the axes of the brokenaxes plot change, or just the position of the entire brokenaxes plot?
In the meantime you should be able to get your desired results by tweaking hspace
and wspace
in GridSpec
The position of the entire plot. Yes I started to tweak the GridSpec
I have having a hard time with BrokenAxis, with Matplotlib completely clipping the x and y labels of a plot. Tight/constrained layouts were not solving the problem (and also moving the line breaks as mentioned above.) In my case, the figure was small (2.75"x3"), where matplotlib can have a hard time placing axes into the plot area.
I eventually found that the issue is the default x & y offsets, set with the labelpad argument for BrokenAxis.set_*_axis()
function. By passing GridSpec left and bottom parameters like this
bax = brokenaxes.brokenaxes(xlims=((L,R) left = 0.25, bottom = 0.25)
and then setting the labels as
bax.set_xlabel("x label", labelpad = 0)
bax.set_ylabel("y label", labelpad = 0)
,
I got a the desired result, with labels on the figure -- the same outcome as tight_layout() would have on a simpler figure. I'm not sure whether or not there is a way to make this automatic, but this manual solution does let you use this package to create small plots that save correctly with plt.savefig()
.
fig.tight_layout() should work now