Code to plot joint KDE (useful for Ramachandran plots)

This commit is contained in:
Kevin Wu
2022-08-27 18:20:56 -07:00
parent 3d2662e1a3
commit 95669c9d43

View File

@@ -22,6 +22,27 @@ PLOT_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "plots")
assert os.path.isdir(PLOT_DIR)
def plot_joint_kde(
x_values, y_values, show_axes: bool = True, fname: Optional[str] = None, **kwargs
):
"""
Plot a density scatter plot (KDE) of the values. kwargs are passed to
ax.set()
Useful for plotting Ramachandran plot - x = phi, y = psi
https://proteopedia.org/wiki/index.php/Ramachandran_Plots
"""
fig, ax = plt.subplots(dpi=300)
sns.kdeplot(x=x_values, y=y_values, levels=25, fill=True, ax=ax)
if show_axes:
ax.axvline(0, color="grey", alpha=0.5)
ax.axhline(0, color="grey", alpha=0.5)
ax.set(**kwargs)
if fname is not None:
fig.savefig(fname, bbox_inches="tight")
return fig
def plot_val_dists_at_t(
dset,
t: int,