def test5(): df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mpg_ggplot2.csv") DrawTools.init() DrawTools.stripplot(df, 'class', 'hwy') DrawTools.boxplot(df, 'class', 'hwy', vertical=True) # sns.boxplot(x='class', y='hwy', data=df, notch=False) plt.show()
def test8(): data = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/mpg_ggplot2.csv") DrawTools.init() fig = plt.figure(figsize=(16, 10), dpi=80) grid = plt.GridSpec(4, 4, hspace=0.5, wspace=0.2) ax_main = fig.add_subplot(grid[:-1, :-1]) ax_right = fig.add_subplot(grid[:-1, -1], xticklabels=[], yticklabels=[]) ax_bottom = fig.add_subplot(grid[-1, :-1], xticklabels=[], yticklabels=[]) # displ 发动机排量(L) # hwy 公路里程/加仑 DrawTools.scatter(data=data, feature_x='displ', feature_y='hwy', feature_c='manufacturer', feature_s='cty', ax=ax_main, xlim=(1, 7), ylim=(0, 50)) DrawTools.font_desc(ax_main, title='边缘直方图 \n 发动机排量 vs 公路里程/加仑', xlabel='发动机排量(L)', ylabel='公里路程/加仑') # 对右侧和下方绘制箱线图 DrawTools.boxplot(data, 'hwy', vertical=True, color="red", ax=ax_right) DrawTools.boxplot(data, 'displ', vertical=False, color="red", ax=ax_bottom) ax_bottom.set(xlabel='') ax_right.set(ylabel='') xlabels = ax_main.get_xticks().tolist() # 将现有的标尺取出来,转化为带一位小数的浮点数 ax_main.set_xticklabels(xlabels) # 再将带一位小数的浮点数变成标尺 plt.show()