Open vkav opened 5 years ago
plt.xticks
in each plot - but it's not obvious how to do that. add_at_risk_counts
is a bit fragile and underdeveloped, so I'm not surprised it fails with many subplots. This could be a problem though: https://github.com/CamDavidsonPilon/lifelines/blob/master/lifelines/plotting.py#L167One suggestion, if you comfortable with it, is to copy-paste the function into your local script (and any other necessary functions like is_latex_enabled
), and play around with the function locally.
If you happen to get something that works, I'd love to see the solution!
Thanks for the feedback.
Playing with the function itself was the next step, thought to check first if there was an obvious solution. Agree, tight_layout may be contributing, also the sns.despine I use might be at fault.
Will update if I get it to work, thanks again!
An update;
By removing plt.tight_layout()
and adjusting the values in ax2_ypos = -0.15 * 6.0 / fig.get_figheight()
, I could get it to work.
Still some of the yticks labels in the inner subplots are missing, but I think I've exhausted my matplotlib skills. One could do sharey=True
though and get around it.
Cheers
Hi,
Had some issues with the add_at_risk_counts option when plotting KM curves.
Is there a way to have the numbers align with the xtick labels?
When I try using it in subplots, its has a weird behavior; A horizontal line appears between it and the x-axis (which is not there when plotting a single axes) plus the xlabel is buried underneath it. I tried playing with subplots_adjust to move the at_risk box away from the actual plot but I have to use extreme values and the plot looks then looks bad. Also, ytick labels become messed up, for example they are not visible for some of the subplots. Attached an example figure plus code.
Any help would be greatly appreciated.
Thanks!
Code to make the figure