python - How to add manually customised seaborn plots to JointGrid/jointplot -


i want use seaborn jointgrid/jointplot.

in middle add sns.regplot. on margins 2 sns.distplots or histograms.

thats not problem, custmize 3 pplots differently , add different fiiting functions , labels 3 of them.

but cant solve problem, how instances of plots if use predifined method:

g = sns.jointgrid(x="total_bill", y="tip", data=tips) g = g.plot(sns.regplot, sns.distplot) 

to manually manipulated those. or other way around create 1 regplot , 2 distplot instances, define way wnat , add them jointgrid, in meaning of, unfortinaltely, these below methods don't exist or don't work way:

g = sns.jointgrid(x="total_bill", y="tip", data=tips) g.add_joint(myreg)           # great doesn't work g.ax_marg_x.add(mydist1)     # invented code g.ax_marg_y.add(mydist2)     # show you, way i'd solve issue 

can give me advice, how around issue?

well, documentation has few examples. if want same distplot on both marginals:

g = sns.jointgrid(x="total_bill", y="tip", data=tips) g = g.plot_joint(plt.scatter, color=".5", edgecolor="white") g = g.plot_marginals(sns.distplot, kde=true, color=".5") 

or if want different plot on each marginal

g = sns.jointgrid(x="total_bill", y="tip", data=tips) g = g.plot_joint(sns.regplot, color="m") _ = g.ax_marg_x.hist(tips["total_bill"], color="b", alpha=.6,                      bins=np.arange(0, 60, 5)) _ = g.ax_marg_y.hist(tips["tip"], color="r", alpha=.6,                      orientation="horizontal",                      bins=np.arange(0, 12, 1)) 

and took 2 seconds of experimenting make sure pass own custom plot functions both marginals , jointplot, , had set breakpoint figure out parameter determined orientation of marginal plot

def customjoint(x,y,*args,**kwargs):     plt.scatter(x,y,color='red') def custommarginal(x,*args,**kwargs):     sns.distplot(x,color='green', vertical=kwargs['vertical'])  g = sns.jointgrid(x="total_bill", y="tip", data=tips) g = g.plot(customjoint, custommarginal) 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -