#Joint and marginal histograms using seaborn library
import matplotlib.pyplot as plt
#conda install -c anaconda seaborn
import seaborn as sns
sns.set_theme(style="ticks")

def main():
    # Load the planets dataset and initialize the figure
    planets = sns.load_dataset("planets")
    g = sns.JointGrid(data=planets, x="year", y="distance", marginal_ticks=True)

    # Set a log scaling on the y axis
    g.ax_joint.set(yscale="log")

    # Create an inset legend for the histogram colorbar
    cax = g.figure.add_axes([.15, .55, .02, .2])

    # Add the joint and marginal histogram plots
    g.plot_joint(
        sns.histplot, discrete=(True, False),
        cmap="light:#03012d", pmax=.8, cbar=True, cbar_ax=cax
        )
    g.plot_marginals(sns.histplot, element="step", color="#03012d")
    plt.savefig("ex379.png", dpi=100)
    plt.show()

if __name__ == '__main__':
    main()

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading