python 3.x - Getting a single merged histogram for two different variable but want two different plot -


python code plotting histogram

 seaborn.distplot(sub2["s2aq16a"].dropna(), kde=false); plt.xlabel('age') plt.title('age when started drinking')  seaborn.distplot(sub2["sibno"].dropna(), kde=false); plt.xlabel('no. of siblings') plt.title('no. of siblings alcoholic') 

i expected output 2 histogram individual variables.but got histogram both variable merged in one. here screenshot of output.

enter image description here

if run code 1 one plotting histogram single variable while leaving code plotting histogram of other variable comment, correct output.

enter image description here

you plotting both histograms on same axes. if want them separate, plot them on different axes. here's 1 way of doing it.

fig, axes = plt.subplots(2, 1) seaborn.distplot(sub2["s2aq16a"].dropna(), kde=false, ax=axes[0]); axes[0].set_xlabel('age') axes[0].set_title('age when started drinking')  seaborn.distplot(sub2["sibno"].dropna(), kde=false, ax=axes[1]); axes[1].set_xlabel('no. of siblings') axes[1].set_title('no. of siblings alcoholic')  plt.tight_layout() 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -