Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

plots of all feature distributions by class

I want to plot the distribution of features in my dataset, So I go like this:

import pandas as pd
import numpy as np

x = ['P'] * 250 + ['Q'] * 350 + ['R'] * 200
y = np.random.randn(800)
df = pd.DataFrame({'Code':x, 'Value':y})

df['Value'].hist(by=df['Code'])

Output:

But I would like to impose the same scaling on axes in both feature plots, so it is easy to compare.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

As stated in the docs, use sharey=True:

sharey : bool, default False

In case subplots=True, share y axis and set some y axis labels to invisible.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

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

Continue reading