python - Matplotlib/Pandas: How to plot multiple scatterplots within different locations in the same plot? -
i have 2 pandas dataframes, plot within same plot. these 2 samples, , contrast properties, example:
the x axis has 2 locations, left first dataset, , right second dataset.
in matplotlib, 1 can plot multiple datasets within same plot:
import matplotlib.pyplot plt x = range(100) y = range(100,200) fig = plt.figure() ax1 = fig.add_subplot(111) ax1.scatter(x[:4], y[:4], s=10, c='b', marker="s", label='first') ax1.scatter(x[40:],y[40:], s=10, c='r', marker="o", label='second') plt.show()
however,
(1) how separate datasets 2 compartmentalized locations first example?
(2) how accomplish 2 pandas dataframes? merge them , specify 2 locations plotting?
use return_type='axes'
data1.boxplot
return matplotlib axes object. pass axes second call boxplot using ax=ax
. cause both boxplots drawn on same axes.
ax = df1.plot() df2.plot(ax=ax) a1=a[['a','time']] ax = a1.boxplot(by='time', meanline=true, showmeans=true, showcaps=true, showbox=true, showfliers=false, return_type='axes') a2 = a[['c','time']] a2.boxplot(by='time', meanline=true, showmeans=true, showcaps=true, showbox=true, showfliers=false, ax=ax)
Comments
Post a Comment