- How can bar labels be added to the tops of bars in the x and y margins of a
seaborn.joinplotorsns.JointGrid? - How can
matplotlib.pyplot.bar_label, as shown in How to add value labels on a bar chart, be applied to the bars in the margins?
import seaborn as sns
# sample data
planets = sns.load_dataset('planets')
# plot
g = sns.jointplot(data=planets, x='distance', y='orbital_period', color='purple', marginal_ticks=True, marker='.',
marginal_kws=dict(bins=10, fill=True, log_scale=True, color='purple', stat='probability'))
g.plot_joint(sns.kdeplot, color='purple', zorder=0, levels=10, fill=True, thresh=0.1)

g.ax_marg_xg.ax_marg_yhue=.maptlotlib.pyplot.bar_label, which don't need to be restated here.python 3.10,matplotlib 3.5.1,seaborn 0.11.2.bar_labelis available frommatplotlib 3.4.0:=) are available frompython 3.8[v.get_height().round(3) if v.get_height() > 0 else '' for v in ax_xm.containers[0]]without:=.