python - show two plot together in Matplotlib like show(fig1,fig2) -
in general, don't have problem put 2 plots in figure plot(a);plot(b)
in matplotlib. using particular library generate figure , want overlay boxplot. both generated matplotlib. think should fine can see 1 plot. here code. using beeswarm , here its ipython notebook. can plot beeswarm or boxplot not both in figure. main goal trying save column scatter plot , boxplot figure in pdf. thanks,
from beeswarm import beeswarm fig=plt.figure() figure(figsize=(5,7)) ax1=plt.subplot(111) fig.ylim=(0,11) d2 = np.random.random_integers(10,size=100) beeswarm(d2,col="red",method="swarm",ax=ax1,ylim=(0,11)) boxplot(d2)
the problem positioning of box plot. default positioning list starts 1 shifts plot 1 , beeswarm plot sits on 0.
so plots in different places of canvas.
i modified code little bit , seems solve problem.
from beeswarm import beeswarm fig = plt.figure(figsize=(5,7)) ax1 = fig.add_subplot(111) # here may want use ax1.set_ylim(0,11) instead fig.ylim=(0,11) ax1.set_ylim(0,11) d2 = np.random.random_integers(10,size=100) beeswarm(d2,col="red",method="swarm",ax=ax1,ylim=(0,11)) boxplot(d2,positions=[0])
cheers
Comments
Post a Comment