Replies: 2 comments
-
I tried doing it with The only problem is that the heatmap has kind of an offset with the marginal distributions... If anyone knows how to fix it, feel welcome to contribute Option 1: Without setting limits# _toplot = pd.crosstab(...)
grid = sns.JointGrid()
sns.heatmap(_toplot, ax=grid.ax_joint, cbar=False, annot=True, fmt='g')
sns.barplot(_toplot.sum(), ax=grid.ax_marg_x)
sns.barplot(_toplot.sum(axis=1), ax=grid.ax_marg_y, orient='h')
grid.ax_joint.set_xlabel('Día de votación')
grid.ax_joint.set_ylabel('Día de creación')
grid.ax_joint.xaxis.set_tick_params(rotation=30)
grid.ax_joint.yaxis.set_tick_params(rotation=0) Option 2: With limitsI tried adding these two lines to "fix" the heatmap, but then part of the countplot gets cut T.T grid.ax_joint.set_xlim(0, 7)
grid.ax_joint.set_ylim(0, 7) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Done! I just had to remove .5 to every x in the bar # _toplot = pd.crosstab(...)
grid = sns.JointGrid()
sns.heatmap(_toplot, ax=grid.ax_joint, cbar=False, annot=True, fmt='g')
sns.barplot(_toplot.sum(), ax=grid.ax_marg_x, width=1)
sns.barplot(_toplot.sum(axis=1), ax=grid.ax_marg_y, orient='h', width=1)
_off = .5
# Fix x
_xmin, _xmax = grid.ax_joint.get_xlim()
grid.ax_joint.set_xlim(_xmin+_off, _xmax+_off)
for bar in grid.ax_marg_x.containers[0]:
bar.set_x(bar.get_x() + _off)
# Fix y
_ymin, _ymax = grid.ax_joint.get_ylim()
grid.ax_joint.set_ylim(_ymin+_off, _ymax+_off)
for bar in grid.ax_marg_y.containers[0]:
bar.set_y(bar.get_y() + _off)
grid.ax_joint.xaxis.set_tick_params(rotation=30)
grid.ax_joint.yaxis.set_tick_params(rotation=0)
grid.ax_joint.set_xlabel('Día de votación')
grid.ax_joint.set_ylabel('Día de creación') |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
heatmap()
is very useful for confusion matrices and the like, in particular withannot = True
. Still, it would be nice to be able to see the marginal distributions as well, much like withjointplot()
. That would allow to assess imbalanced distributions much better.Beta Was this translation helpful? Give feedback.
All reactions