pycore.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:sci-pype 作者: jay-johnson 项目源码 文件源码
def sb_scatter(self, req, debug=False):

        image_list      = []

        image_filename  = req["ImgFile"]

        import seaborn as sns 
        import numpy as np
        from matplotlib import pyplot
        import matplotlib.pyplot as plt
        import matplotlib.dates as mdates
        from matplotlib.patches import Rectangle
        from matplotlib.finance import volume_overlay
        import pandas as pd
        from pandas.tseries.offsets import BDay

        source_df       = req["SourceDF"]
        ds_name         = req["DSName"]

        sns.set_style("whitegrid", {'axes.grid' : True})
        sns.color_palette("Set1", n_colors=8, desat=.5)

        cur_xlabel      = "measurement"
        cur_ylabel      = "value"
        cur_hue         = "ResultLabel"
        cur_width       = 10.0
        cur_height      = 10.0
        if "X" in req:
            cur_xlabel  = str(req["X"])
        if "Y" in req:
            cur_ylabel  = str(req["Y"])
        if "Width" in req:
            cur_width   = float(req["Width"])
        if "Height" in req:
            cur_height  = float(req["Height"])
        if "Hue" in req:
            cur_hue     = str(req["Hue"])
        # end of parsing inputs

        # Add custom plots here

        plt.figure(figsize=(cur_width, cur_height))
        ax              = sns.swarmplot(x=cur_xlabel, y=cur_ylabel, hue=cur_hue, data=source_df)

        if debug:
            self.lg("Saving File(" + str(image_filename) + ")", 6)

        self.pd_add_footnote(ax.figure)
        ax.figure.savefig(image_filename)
        image_list.append(image_filename)

        if req["ShowPlot"] == True:
            plt.show()

        return image_list
    # end of sb_scatter
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号