1193 lines
43 KiB
Python
1193 lines
43 KiB
Python
# # # # dd = """ title = request.GET.get("title") # 标题
|
||
# # # # title_size = request.GET.get("title_size") # 标题字号
|
||
# # # # xticks = request.GET.get("xticks") # x轴旋转角度
|
||
# # # # xlabel = request.GET.get("xlabel") # x轴名称
|
||
# # # # yticks = request.GET.get("yticks") # y旋转角度
|
||
# # # # ylabel = request.GET.get("ylabel") # y轴名称
|
||
# # # # file_id = request.GET.get("file_id") # 工作编号
|
||
# # # # range_column = request.GET.get("range_column") # 范围列
|
||
# # # # range_data = request.GET.get("range_data") # 范围
|
||
# # # # x_col = request.GET.get("x_col") # x列
|
||
# # # # y_col = request.GET.get("y_col") # y列
|
||
# # # # k = request.GET.get("k") # 增加编号解决缓存问题"""
|
||
# # # # a = []
|
||
# # # # for i in dd.split("\n"):
|
||
# # # # ddd = i.split(" ")[0]
|
||
# # # # print(f'{ddd}: (document.getElementById("{ddd}").value),')
|
||
# # # # a.append(ddd)
|
||
# # # #
|
||
# # # # print(",".join(a))
|
||
# # #
|
||
# # #
|
||
# # # import matplotlib.pyplot as plt
|
||
# # # import numpy as np
|
||
# # # import pandas as pd
|
||
# # # import seaborn as sns
|
||
# # #
|
||
# # #
|
||
# # # def Bubble_plot_with_Encircling(file_path, chart_out_path, out_path, range_column, range_data, x_col, y_col, title,
|
||
# # # xticks, yticks, x_name, y_name):
|
||
# # # plt.figure(figsize=(9.4, 4.25), dpi=200)
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # df_select = df.loc[df[range_column].isin(range_data), :] # 用那一列规范 范围
|
||
# # #
|
||
# # # gridobj = sns.lmplot(
|
||
# # # x=x_col,
|
||
# # # y=y_col,
|
||
# # # hue=range_column,
|
||
# # # data=df_select,
|
||
# # # height=3,
|
||
# # # palette='Set1',
|
||
# # # scatter_kws=dict(s=60, linewidths=.7, edgecolors='black'))
|
||
# # #
|
||
# # # # Decorations
|
||
# # # sns.set(style="whitegrid", font_scale=1.5)
|
||
# # # gridobj.set(xlim=(0.5, 7.5), ylim=(10, 50))
|
||
# # # gridobj.fig.set_size_inches(10, 6)
|
||
# # # plt.title(title)
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=xticks, fontsize=10)
|
||
# # #
|
||
# # # # xy轴的名称
|
||
# # # plt.xlabel(x_name, fontdict={'fontsize': 10})
|
||
# # # plt.ylabel(y_name, fontdict={'fontsize': 10})
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # def Each_regression_line_in_its_own_column(file_path, chart_out_path, out_path, range_column, range_data, x_col, y_col,
|
||
# # # title, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # df_select = df.loc[df[range_column].isin(range_data), :]
|
||
# # # plt.figure(figsize=(5, 3), dpi=200)
|
||
# # # gridobj = sns.lmplot(x=x_col,
|
||
# # # y=y_col,
|
||
# # # data=df_select,
|
||
# # # robust=True,
|
||
# # # palette='Set1',
|
||
# # # col=range_column,
|
||
# # # scatter_kws=dict(s=60, linewidths=.7, edgecolors='black'))
|
||
# # #
|
||
# # # # Decorations
|
||
# # # sns.set(style="whitegrid", font_scale=1.5)
|
||
# # # gridobj.fig.set_size_inches(10, 6)
|
||
# # #
|
||
# # # plt.title(title)
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # # xy轴的名称
|
||
# # # plt.xlabel(x_name, fontdict={'fontsize': 10})
|
||
# # # plt.ylabel(y_name, fontdict={'fontsize': 10})
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Each_regression_line_in_its_own_column(file_path="./datasets/mpg_ggplot2.csv", chart_out_path="./Marginal_Boxplot.png",
|
||
# # # # out_path="./ss", range_column="cyl", range_data=[4, 8], x_col='displ',
|
||
# # # # y_col='hwy', title='ddd', xticks=3, yticks=3, x_name='fsfs', y_name='sfsf')
|
||
# # #
|
||
# # #
|
||
# # # # 5、抖动图(Jittering with stripplot
|
||
# # #
|
||
# # # def Jittering_with_stripplot(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # fig, ax = plt.subplots(figsize=(5, 3), dpi=180)
|
||
# # # print(fig, ax)
|
||
# # # sns.stripplot(df[x_col],
|
||
# # # df[y_col],
|
||
# # # jitter=0.25,
|
||
# # # size=8,
|
||
# # # ax=ax,
|
||
# # # linewidth=.5,
|
||
# # # palette='Set1')
|
||
# # #
|
||
# # # sns.set(style="whitegrid", font_scale=1.1)
|
||
# # # plt.title(title)
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.legend(fontsize=10)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # # xy轴的名称
|
||
# # # plt.xlabel(x_name, fontdict={'fontsize': 10})
|
||
# # # plt.ylabel(y_name, fontdict={'fontsize': 10})
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Jittering_with_stripplot(file_path="./datasets/mpg_ggplot2.csv", chart_out_path="./Marginal_Boxplot.png",
|
||
# # # # out_path="./ss", range_column="cyl", range_data=[4, 8], x_col='displ',
|
||
# # # # y_col='hwy', title='ddd', xticks=3, yticks=3, x_name='fsfs', y_name='sfsf')
|
||
# # #
|
||
# # #
|
||
# # # def Marginal_Histogram(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name, color1, color2):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # # Create Fig and gridspec
|
||
# # # fig = plt.figure(figsize=(9.4, 4.25), dpi=200)
|
||
# # #
|
||
# # # grid = plt.GridSpec(4, 4, hspace=0.5, wspace=0.2)
|
||
# # #
|
||
# # # # Define the axes
|
||
# # # 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, 0:-1], xticklabels=[], yticklabels=[])
|
||
# # #
|
||
# # # # Scatterplot on main ax
|
||
# # # ax_main.scatter(x_col,
|
||
# # # y_col,
|
||
# # # c=df.manufacturer.astype('category').cat.codes,
|
||
# # # alpha=.9,
|
||
# # # data=df,
|
||
# # # cmap="Set1",
|
||
# # # edgecolors='gray',
|
||
# # # linewidths=.5)
|
||
# # #
|
||
# # # # histogram on the right
|
||
# # # ax_bottom.hist(df[x_col],
|
||
# # # 40,
|
||
# # # histtype='stepfilled',
|
||
# # # orientation='vertical',
|
||
# # # color=color1)
|
||
# # # ax_bottom.invert_yaxis()
|
||
# # #
|
||
# # # # histogram in the bottom
|
||
# # # ax_right.hist(df[y_col],
|
||
# # # 40,
|
||
# # # histtype='stepfilled',
|
||
# # # orientation='horizontal',
|
||
# # # color=color2)
|
||
# # #
|
||
# # # ax_main.title.set_fontsize(fontsize=int(title_s))
|
||
# # #
|
||
# # # ax_main.set(title=title,
|
||
# # # xlabel=x_name,
|
||
# # # ylabel=y_name)
|
||
# # #
|
||
# # # for item in ([ax_main.xaxis.label, ax_main.yaxis.label] +
|
||
# # # ax_main.get_xticklabels() + ax_main.get_yticklabels()):
|
||
# # # item.set_fontsize(10)
|
||
# # #
|
||
# # # xlabels = ax_main.get_xticks().tolist()
|
||
# # # ax_main.set_xticklabels(xlabels)
|
||
# # #
|
||
# # # plt.savefig(chart_out_path) # 保存图片
|
||
# # #
|
||
# # # plt.legend(fontsize=10)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Marginal_Histogram(file_path="./datasets/mpg_ggplot2.csv", chart_out_path="Marginal_Boxplot.png",
|
||
# # # # out_path="./ss", x_col='displ',
|
||
# # # # y_col='hwy', title='title', title_s=12, xticks=3, yticks=3, x_name='x_name', y_name='y_name', color1="#098154", color2='#098154')
|
||
# # #
|
||
# # #
|
||
# # # def Correllogram(file_path, chart_out_path, out_path,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name, size, color, weight):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # plt.figure(figsize=(5, 3), dpi=200)
|
||
# # # sns.heatmap(
|
||
# # # df.corr(),
|
||
# # # xticklabels=df.corr().columns,
|
||
# # # yticklabels=df.corr().columns,
|
||
# # # cmap='Set1',
|
||
# # # center=0,
|
||
# # # annot=True,
|
||
# # # annot_kws={
|
||
# # # 'size': size,
|
||
# # # 'weight': weight,
|
||
# # # 'color': color
|
||
# # # },
|
||
# # # )
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.legend(fontsize=10)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # # xy轴的名称
|
||
# # # plt.xlabel(x_name, fontdict={'fontsize': 10})
|
||
# # # plt.ylabel(y_name, fontdict={'fontsize': 10})
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Correllogram(file_path="./datasets/mtcars.csv",
|
||
# # # # chart_out_path="Correllogram.png",
|
||
# # # # out_path="./ss",
|
||
# # # # title='title', title_s=12, xticks=3, yticks=3, x_name='x_name', y_name='y_name', size=7, color='#098154', weight=5)
|
||
# # #
|
||
# # #
|
||
# # # def Marginal_Boxplot(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # # 边缘箱图(Marginal Boxplot)
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # fig = plt.figure(figsize=(9.4, 4.25), dpi=100)
|
||
# # # grid = plt.GridSpec(
|
||
# # # 4, 4, hspace=0.5, wspace=0.2
|
||
# # # )
|
||
# # #
|
||
# # # # Define the axes
|
||
# # # 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, 0:-1], xticklabels=[], yticklabels=[])
|
||
# # #
|
||
# # # # Scatterplot on main ax
|
||
# # # ax_main.scatter(x_col,
|
||
# # # y_col,
|
||
# # # c=df.manufacturer.astype('category').cat.codes,
|
||
# # # alpha=.9,
|
||
# # # data=df,
|
||
# # # cmap="Set1",
|
||
# # # edgecolors='black',
|
||
# # # linewidths=.5)
|
||
# # #
|
||
# # # # Add a graph in each part
|
||
# # # sns.boxplot(df[y_col], ax=ax_right, orient="v", linewidth=1, palette='Set1')
|
||
# # # sns.boxplot(df[x_col], ax=ax_bottom, orient="h", linewidth=1, palette='Set1')
|
||
# # #
|
||
# # # ax_bottom.set(xlabel='')
|
||
# # # ax_right.set(ylabel='')
|
||
# # #
|
||
# # # ax_main.title.set_fontsize(fontsize=int(title_s))
|
||
# # # ax_main.set(title=title,
|
||
# # # xlabel=x_name,
|
||
# # # ylabel=y_name)
|
||
# # #
|
||
# # # for item in ([ax_main.xaxis.label, ax_main.yaxis.label] +
|
||
# # # ax_main.get_xticklabels() + ax_main.get_yticklabels()):
|
||
# # # item.set_fontsize(11)
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.legend(fontsize=10)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # # xy轴的名称
|
||
# # # plt.xlabel(x_name, fontdict={'fontsize': 10})
|
||
# # # plt.ylabel(y_name, fontdict={'fontsize': 10})
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Marginal_Boxplot(file_path="./datasets/mpg_ggplot2.csv", chart_out_path="Marginal_Boxplot.png",
|
||
# # # # out_path="./ss", x_col='displ',
|
||
# # # # y_col='hwy', title='title', title_s=12, xticks=3, yticks=3, x_name='x_name', y_name='y_name')
|
||
# # #
|
||
# # #
|
||
# # # # 10、矩阵图 (Pairwise Plot)
|
||
# # # def Pairwise_Plot(file_path, chart_out_path, out_path, title, title_s, features):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # plt.figure(figsize=(9.4, 4.25), dpi=100)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # # sns.pairplot(df,
|
||
# # # hue=features,
|
||
# # # palette='Set1',
|
||
# # # plot_kws=dict(s=80, edgecolor="white", linewidth=2.5))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # #
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Pairwise_Plot(file_path="./datasets/iris_test.csv", chart_out_path="Pairwise_Plot.png",
|
||
# # # # out_path="./ss", title='title', title_s=12,features="Species")
|
||
# # #
|
||
# # #
|
||
# # # # plt.title(title, fontsize=int(title_s))
|
||
# # # def Diverging_Bars(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # x = df.loc[:, [x_col]]
|
||
# # # df[x_col + "_z"] = (x - x.mean()) / x.std()
|
||
# # # df['colors'] = ['red' if x < 0 else 'green' for x in df[x_col + "_z"]]
|
||
# # # df.sort_values(x_col + "_z", inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # #
|
||
# # # # Draw plot
|
||
# # # plt.figure(figsize=(9.4, 4.25), dpi=80)
|
||
# # # plt.hlines(y=df.index,
|
||
# # # xmin=0,
|
||
# # # xmax=df.mpg_z,
|
||
# # # color=df.colors,
|
||
# # # alpha=0.8,
|
||
# # # linewidth=5)
|
||
# # #
|
||
# # # # Decorations
|
||
# # # plt.gca().set(ylabel=y_name, xlabel=x_name)
|
||
# # # plt.yticks(df.index, df[y_col], fontsize=12)
|
||
# # # plt.xticks(fontsize=12)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.grid(linestyle='--', alpha=0.5)
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Diverging_Bars(file_path="./datasets/mtcars.csv",
|
||
# # # # chart_out_path="Diverging_Bars_vertical.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col='mpg',
|
||
# # # # y_col='cars',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=3,
|
||
# # # # yticks=3,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name')
|
||
# # #
|
||
# # # def Diverging_Bars_vertical(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # x = df.loc[:, [y_col]]
|
||
# # #
|
||
# # # df[y_col + 'z'] = (x - x.mean()) / x.std()
|
||
# # # df['colors'] = ['red' if x < 0 else 'green' for x in df[y_col + 'z']]
|
||
# # # df.sort_values(y_col + 'z', inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # # plt.gca().set(ylabel=y_name, xlabel=x_name)
|
||
# # # # Draw plot
|
||
# # # plt.figure(figsize=(10, 6), dpi=80)
|
||
# # # plt.vlines(x=df.index,
|
||
# # # ymin=0,
|
||
# # # ymax=df[y_col + 'z'],
|
||
# # # color=df.colors,
|
||
# # # alpha=0.8,
|
||
# # # linewidth=5)
|
||
# # # for y, x, tex in zip(df[y_col + 'z'], df.index, df[y_col + 'z']):
|
||
# # # t = plt.text(x,
|
||
# # # y + 0.2,
|
||
# # # round(tex, 1),
|
||
# # # horizontalalignment='center',
|
||
# # # fontdict={
|
||
# # # 'color': 'black' if x < 0 else 'black',
|
||
# # # 'size': 8
|
||
# # # })
|
||
# # #
|
||
# # # # Decorations
|
||
# # # plt.xticks(df.index, df[x_col], fontsize=12, rotation=90)
|
||
# # # plt.yticks(fontsize=12)
|
||
# # # plt.title(title, fontdict={'size': int(title_s)})
|
||
# # # plt.grid(linestyle='--', alpha=0.5)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Diverging_Bars_vertical(file_path="./datasets/mtcars.csv",
|
||
# # # # chart_out_path="Diverging_Bars_vertical.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col='cars',
|
||
# # # # y_col='mpg',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=3,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name')
|
||
# # #
|
||
# # #
|
||
# # # def Ordered_Bar_Chart(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name, color):
|
||
# # # df_raw = pd.read_csv(file_path)
|
||
# # # df = df_raw[[x_col, y_col]].groupby(y_col).apply(lambda x: x.mean())
|
||
# # # df.sort_values(x_col, inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # #
|
||
# # # import matplotlib.patches as patches
|
||
# # #
|
||
# # # plt.gca().set(ylabel=y_name, xlabel=x_name)
|
||
# # #
|
||
# # # fig, ax = plt.subplots(figsize=(9.4, 4.25), facecolor='white', dpi=80)
|
||
# # # ax.vlines(x=df.index,
|
||
# # # ymin=0,
|
||
# # # ymax=df.cty,
|
||
# # # color=color,
|
||
# # # alpha=0.7,
|
||
# # # linewidth=20)
|
||
# # #
|
||
# # # # Annotate Text
|
||
# # # for i, cty in enumerate(df.cty):
|
||
# # # ax.text(i, cty + 0.5, round(cty, 1), horizontalalignment='center')
|
||
# # #
|
||
# # # # Title, Label, Ticks and Ylim
|
||
# # #
|
||
# # # plt.xticks(df.index,
|
||
# # # df.manufacturer.str.upper(),
|
||
# # # rotation=60,
|
||
# # # horizontalalignment='right',
|
||
# # # fontsize=10)
|
||
# # # plt.yticks(fontsize=12)
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.ylim = (0, 30)
|
||
# # #
|
||
# # # # 添加底纹
|
||
# # # p1 = patches.Rectangle((.57, -0.005),
|
||
# # # width=.33,
|
||
# # # height=.13,
|
||
# # # alpha=.1,
|
||
# # # facecolor='green',
|
||
# # # transform=fig.transFigure)
|
||
# # # p2 = patches.Rectangle((.124, -0.005),
|
||
# # # width=.446,
|
||
# # # height=.13,
|
||
# # # alpha=.1,
|
||
# # # facecolor='red',
|
||
# # # transform=fig.transFigure)
|
||
# # # fig.add_artist(p1)
|
||
# # # fig.add_artist(p2)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Ordered_Bar_Chart(file_path="./datasets/mpg_ggplot2.csv",
|
||
# # # # chart_out_path="Ordered_Bar_Chart.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col='cty',
|
||
# # # # y_col='manufacturer',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=3,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name',
|
||
# # # # color="#e66765")
|
||
# # #
|
||
# # #
|
||
# # # # 18、棒棒糖图(Lollipop Chart)
|
||
# # # # 棒棒糖图(Lollipop Chart)
|
||
# # # # Prepare Data
|
||
# # # def Lollipop_Chart(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name, color):
|
||
# # # df_raw = pd.read_csv(file_path)
|
||
# # # df = df_raw[[x_col,
|
||
# # # y_col]].groupby(y_col).apply(lambda x: x.mean())
|
||
# # # df.sort_values(x_col, inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # #
|
||
# # # # Draw plot
|
||
# # # fig, ax = plt.subplots(figsize=(9.4, 4.25), dpi=200)
|
||
# # #
|
||
# # # ax.vlines(x=df.index,
|
||
# # # ymin=0,
|
||
# # # ymax=df.cty,
|
||
# # # color=color,
|
||
# # # alpha=0.7,
|
||
# # # linewidth=4)
|
||
# # #
|
||
# # # ax.scatter(x=df.index, y=df[x_col], s=85, color=color, alpha=0.7)
|
||
# # #
|
||
# # # # Title, Label, Ticks and Ylim
|
||
# # #
|
||
# # # ax.set_xticks(df.index)
|
||
# # # ax.set_xticklabels(df.manufacturer.str.upper(),
|
||
# # # rotation=60,
|
||
# # # fontdict={
|
||
# # # 'horizontalalignment': 'right',
|
||
# # # 'size': 11
|
||
# # # })
|
||
# # # ax.set_ylim(0, 30)
|
||
# # # plt.yticks(fontsize=12)
|
||
# # #
|
||
# # # # Annotate
|
||
# # # for row in df.itertuples():
|
||
# # # ax.text(row.Index,
|
||
# # # row.cty + .5,
|
||
# # # s=round(row.cty, 2),
|
||
# # # horizontalalignment='center',
|
||
# # # verticalalignment='bottom',
|
||
# # # fontsize=12)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Lollipop_Chart(file_path="./datasets/mpg_ggplot2.csv",
|
||
# # # # chart_out_path="Lollipop_Chart.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col='cty',
|
||
# # # # y_col='manufacturer',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=3,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name',
|
||
# # # # color="#e66765")
|
||
# # #
|
||
# # #
|
||
# # # def Dot_Plot(file_path, chart_out_path, out_path, x_col, y_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name, color1, color2):
|
||
# # # df_raw = pd.read_csv(file_path)
|
||
# # # df = df_raw[[x_col,
|
||
# # # y_col]].groupby(y_col).apply(lambda x: x.mean())
|
||
# # # df.sort_values(x_col, inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # #
|
||
# # # # Draw plot
|
||
# # # fig, ax = plt.subplots(figsize=(9.4, 4.25), dpi=200)
|
||
# # # ax.hlines(y=df.index,
|
||
# # # xmin=11,
|
||
# # # xmax=26,
|
||
# # # color=color1,
|
||
# # # alpha=0.7,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dashdot')
|
||
# # # ax.scatter(y=df.index, x=df.cty, s=75, color=color2, alpha=0.7)
|
||
# # #
|
||
# # # ax.set_yticks(df.index)
|
||
# # # ax.set_yticklabels(df.manufacturer.str.title(),
|
||
# # # fontdict={
|
||
# # # 'horizontalalignment': 'right',
|
||
# # # 'fontsize': 12,
|
||
# # # })
|
||
# # #
|
||
# # # ax.set_xlim(10, 27)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Dot_Plot(file_path="./datasets/mpg_ggplot2.csv",
|
||
# # # # chart_out_path="Dot_Plot.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col='cty',
|
||
# # # # y_col='manufacturer',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=3,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name',
|
||
# # # # color2='#3dd0b5',
|
||
# # # # color1='#d5d5d5')
|
||
# # #
|
||
# # #
|
||
# # # def Slope_Chart(file_path, chart_out_path, out_path, col_1, col_2, col_3,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # import matplotlib.lines as mlines
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # def newline(p1, p2):
|
||
# # # ax = plt.gca()
|
||
# # # l = mlines.Line2D([p1[0], p2[0]], [p1[1], p2[1]],
|
||
# # # color='red' if p1[1] - p2[1] > 0 else 'green',
|
||
# # # marker='o',
|
||
# # # markersize=6)
|
||
# # # ax.add_line(l)
|
||
# # # return l
|
||
# # #
|
||
# # # fig, ax = plt.subplots(1, 1, figsize=(9.4, 4.25), dpi=80)
|
||
# # #
|
||
# # # # Vertical Lines
|
||
# # # ax.vlines(x=1,
|
||
# # # ymin=500,
|
||
# # # ymax=13000,
|
||
# # # color='black',
|
||
# # # alpha=0.7,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # # ax.vlines(x=3,
|
||
# # # ymin=500,
|
||
# # # ymax=13000,
|
||
# # # color='black',
|
||
# # # alpha=0.7,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # #
|
||
# # # ax.scatter(y=df[col_1],
|
||
# # # x=np.repeat(1, df.shape[0]),
|
||
# # # s=10,
|
||
# # # color='black',
|
||
# # # alpha=0.7)
|
||
# # # ax.scatter(y=df[col_2],
|
||
# # # x=np.repeat(3, df.shape[0]),
|
||
# # # s=10,
|
||
# # # color='black',
|
||
# # # alpha=0.7)
|
||
# # #
|
||
# # # # Line Segmentsand Annotation
|
||
# # # for p1, p2, c in zip(df[col_1], df[col_2], df[col_3]):
|
||
# # # newline([1, p1], [3, p2])
|
||
# # # ax.text(1 - 0.05,
|
||
# # # p1,
|
||
# # # c + ', ' + str(round(p1)),
|
||
# # # horizontalalignment='right',
|
||
# # # verticalalignment='center',
|
||
# # # fontdict={'size': 14})
|
||
# # # ax.text(3 + 0.05,
|
||
# # # p2,
|
||
# # # c + ', ' + str(round(p2)),
|
||
# # # horizontalalignment='left',
|
||
# # # verticalalignment='center',
|
||
# # # fontdict={'size': 14})
|
||
# # #
|
||
# # # # 'Before' and 'After' Annotations
|
||
# # # ax.text(1 - 0.05,
|
||
# # # 13000,
|
||
# # # 'BEFORE',
|
||
# # # horizontalalignment='right',
|
||
# # # verticalalignment='center',
|
||
# # # fontdict={
|
||
# # # 'size': 15,
|
||
# # # 'weight': 700
|
||
# # # })
|
||
# # # ax.text(3 + 0.05,
|
||
# # # 13000,
|
||
# # # 'AFTER',
|
||
# # # horizontalalignment='left',
|
||
# # # verticalalignment='center',
|
||
# # # fontdict={
|
||
# # # 'size': 15,
|
||
# # # 'weight': 700
|
||
# # # })
|
||
# # #
|
||
# # # # Decoration
|
||
# # #
|
||
# # # ax.set(xlim=(0, 4), ylim=(0, 14000))
|
||
# # #
|
||
# # # ax.set_xticks([1, 3])
|
||
# # # ax.set_xticklabels([col_1, col_2], fontdict={'size': 15, 'weight': 700})
|
||
# # # plt.yticks(np.arange(500, 13000, 2000), rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # # Lighten borders
|
||
# # # plt.gca().spines["top"].set_alpha(.0)
|
||
# # # plt.gca().spines["bottom"].set_alpha(.0)
|
||
# # # plt.gca().spines["right"].set_alpha(.0)
|
||
# # # plt.gca().spines["left"].set_alpha(.0)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Slope_Chart(file_path="./datasets/gdppercap.csv",
|
||
# # # # chart_out_path="Slope_Chart.png",
|
||
# # # # out_path="./ss",
|
||
# # # # col_1="1952",
|
||
# # # # col_2='1957',
|
||
# # # # col_3='continent',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=90,
|
||
# # # # x_name="x_name",
|
||
# # # # y_name="y_name")
|
||
# # #
|
||
# # #
|
||
# # # def Dumbbell_Plot(file_path, chart_out_path, out_path, col_1, col_2, col_3,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # import matplotlib.lines as mlines
|
||
# # #
|
||
# # # # Import Data
|
||
# # # df = pd.read_csv(file_path)
|
||
# # # df.sort_values(col_1, inplace=True)
|
||
# # # df.reset_index(inplace=True)
|
||
# # #
|
||
# # # # Func to draw line segment
|
||
# # # def newline(p1, p2):
|
||
# # # ax = plt.gca()
|
||
# # # l = mlines.Line2D([p1[0], p2[0]], [p1[1], p2[1]], color='#d5695d')
|
||
# # # ax.add_line(l)
|
||
# # # return l
|
||
# # #
|
||
# # # # Figure and Axes
|
||
# # # fig, ax = plt.subplots(1, 1, figsize=(9.4, 4.25), facecolor='#f8f2e4', dpi=80)
|
||
# # #
|
||
# # # # Vertical Lines
|
||
# # # ax.vlines(x=.05,
|
||
# # # ymin=0,
|
||
# # # ymax=26,
|
||
# # # color='black',
|
||
# # # alpha=1,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # # ax.vlines(x=.10,
|
||
# # # ymin=0,
|
||
# # # ymax=26,
|
||
# # # color='black',
|
||
# # # alpha=1,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # # ax.vlines(x=.15,
|
||
# # # ymin=0,
|
||
# # # ymax=26,
|
||
# # # color='black',
|
||
# # # alpha=1,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # # ax.vlines(x=.20,
|
||
# # # ymin=0,
|
||
# # # ymax=26,
|
||
# # # color='black',
|
||
# # # alpha=1,
|
||
# # # linewidth=1,
|
||
# # # linestyles='dotted')
|
||
# # #
|
||
# # # # Points
|
||
# # # ax.scatter(y=df['index'], x=df[col_1], s=50, color='#dc2624')
|
||
# # # ax.scatter(y=df['index'], x=df[col_2], s=50, color='#e87a59')
|
||
# # #
|
||
# # # # Line Segments
|
||
# # # for i, p1, p2 in zip(df['index'], df[col_1], df[col_2]):
|
||
# # # newline([p1, i], [p2, i])
|
||
# # #
|
||
# # # # Decoration
|
||
# # # ax.set_facecolor('#f8f2e4')
|
||
# # #
|
||
# # # ax.set(xlim=(0, .25), ylim=(-1, 27))
|
||
# # # plt.yticks(fontsize=15)
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # # Dumbbell_Plot(file_path="./datasets/health.csv",
|
||
# # # # chart_out_path="Dumbbell_Plot.png",
|
||
# # # # out_path="./ss",
|
||
# # # # col_1="pct_2014",
|
||
# # # # col_2='pct_2013',
|
||
# # # # col_3='continent',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=90,
|
||
# # # # yticks=90,
|
||
# # # # x_name="x_name",
|
||
# # # # y_name="y_name")
|
||
# # #
|
||
# # #
|
||
# # # def Stacked_Histogram_for_Continuous_Variable(file_path, chart_out_path, out_path, x_col, groupby_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # # Prepare data
|
||
# # # x_var = x_col
|
||
# # # groupby_var = groupby_col
|
||
# # # df_agg = df.loc[:, [x_var, groupby_var]].groupby(groupby_var)
|
||
# # # vals = [df[x_var].values.tolist() for i, df in df_agg]
|
||
# # #
|
||
# # # # Draw
|
||
# # # plt.figure(figsize=(9.4, 4.25), dpi=180)
|
||
# # # colors = [plt.cm.Set1(i / float(len(vals) - 1)) for i in range(len(vals))]
|
||
# # # n, bins, patches = plt.hist(vals,
|
||
# # # 30,
|
||
# # # stacked=True,
|
||
# # # density=False,
|
||
# # # color=colors[:len(vals)])
|
||
# # #
|
||
# # # # Decoration
|
||
# # # plt.legend({
|
||
# # # group: col
|
||
# # # for group, col in zip(
|
||
# # # np.unique(df[groupby_var]).tolist(), colors[:len(vals)])
|
||
# # # })
|
||
# # #
|
||
# # # plt.xlabel(x_var)
|
||
# # #
|
||
# # # # plt.ylim(0, 25)
|
||
# # # plt.xticks(ticks=bins[::3], labels=[round(b, 1) for b in bins[::3]])
|
||
# # #
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # (9.4, 4.25)
|
||
# # #
|
||
# # #
|
||
# # # # Stacked_Histogram_for_Continuous_Variable(file_path="./datasets/mpg_ggplot2.csv",
|
||
# # # # chart_out_path="Stacked_Histogram_for_Continuous_Variable.png",
|
||
# # # # out_path="./ss",
|
||
# # # # x_col="displ",
|
||
# # # # groupby_col='class',
|
||
# # # # title='title',
|
||
# # # # title_s=12,
|
||
# # # # xticks=0,
|
||
# # # # yticks=0,
|
||
# # # # x_name='x_name',
|
||
# # # # y_name='y_name')
|
||
# # #
|
||
# # #
|
||
# # # def Density_Plot(file_path, chart_out_path, out_path, x_col, groupby_col,
|
||
# # # title, title_s, xticks, yticks, x_name, y_name):
|
||
# # # df = pd.read_csv(file_path)
|
||
# # #
|
||
# # # # Draw Plot
|
||
# # # plt.figure(figsize=(10, 8), dpi=80)
|
||
# # # sns.kdeplot(df.loc[df['cyl'] == 4, "cty"],
|
||
# # # shade=True,
|
||
# # # color="#01a2d9",
|
||
# # # label="Cyl=4",
|
||
# # # alpha=.7)
|
||
# # # sns.kdeplot(df.loc[df['cyl'] == 5, "cty"],
|
||
# # # shade=True,
|
||
# # # color="#dc2624",
|
||
# # # label="Cyl=5",
|
||
# # # alpha=.7)
|
||
# # # sns.kdeplot(df.loc[df['cyl'] == 6, "cty"],
|
||
# # # shade=True,
|
||
# # # color="#C89F91",
|
||
# # # label="Cyl=6",
|
||
# # # alpha=.7)
|
||
# # # sns.kdeplot(df.loc[df['cyl'] == 8, "cty"],
|
||
# # # shade=True,
|
||
# # # color="#649E7D",
|
||
# # # label="Cyl=8",
|
||
# # # alpha=.7)
|
||
# # #
|
||
# # # # Decoration
|
||
# # # sns.set(style="whitegrid", font_scale=1.1)
|
||
# # #
|
||
# # # plt.legend()
|
||
# # # plt.xticks(rotation=xticks, fontsize=10)
|
||
# # # plt.yticks(rotation=yticks, fontsize=10)
|
||
# # #
|
||
# # # plt.ylabel(y_name, fontsize=12)
|
||
# # # plt.ylabel(x_name, fontsize=12)
|
||
# # #
|
||
# # # plt.title(title, fontsize=int(title_s))
|
||
# # #
|
||
# # # plt.savefig(f"{chart_out_path}") # 保存图片
|
||
# # # plt.savefig(f"{out_path}.png")
|
||
# # # plt.savefig(f"{out_path}.svg")
|
||
# # # plt.savefig(f"{out_path}.pdf")
|
||
# # #
|
||
# # #
|
||
# # # from Bio.Seq import Seq
|
||
# # #
|
||
# # # # my_sequence = Seq(">fjjj/n ATGACGTTGCATG")
|
||
# # # #
|
||
# # # # print ("The sequence is:", my_sequence)
|
||
# # # # #len(my_sequence) 长度
|
||
# # # # print("The length of the sequence is:", len(my_sequence))
|
||
# # # # #反向互补序列
|
||
# # # # print ("Reverse complementary sequence:",my_sequence.reverse_complement())
|
||
# # # # #计算核苷酸的出现次数
|
||
# # # # print("The number of As in the sequence:", my_sequence.count("A"))
|
||
# # # # print("The number of Ts in the sequence:", my_sequence.count("T"))
|
||
# # # # print("The number of Gs in the sequence:", my_sequence.count("G"))
|
||
# # # # print("The number of Cs in the sequence:", my_sequence.count("C"))
|
||
# # # # #计算GC含量
|
||
# # # # C_count=my_sequence.count("C")
|
||
# # # # G_count=my_sequence.count("G")
|
||
# # # # Length=len(my_sequence)
|
||
# # # # GC=(C_count+G_count)/Length
|
||
# # # # print ("GC percentage:","%.2f" % GC)
|
||
# # # # #查找子序列的起始索引
|
||
# # # # print("Found TTG in the sequence at index:", my_sequence.find("TTG"))
|
||
# # # # #翻译
|
||
# # # # print ("protein translation is:",my_sequence.translate())
|
||
# # # tst = """>fjjj
|
||
# # # ATGACGTTGCATG
|
||
# # # >fjjj
|
||
# # # ATGACGTTGCATG
|
||
# # # >fjjj
|
||
# # # ATGACGTTGCATG
|
||
# # # >fjjj
|
||
# # # ATGACGTTGCATG"""
|
||
# # #
|
||
# # # def 反向互补序列(in_seq):
|
||
# # # def in_seq(a):
|
||
# # # a = a.replace("\r", "")
|
||
# # # a_list = a.split(">")[1:]
|
||
# # # data_ = []
|
||
# # # for i in a_list:
|
||
# # # all_seq = []
|
||
# # # for s, j in enumerate(i.split("\n")):
|
||
# # # if s == 0:
|
||
# # # data_.append(f">{j}")
|
||
# # # all_seq.append(j)
|
||
# # # data_.append("".join(all_seq))
|
||
# # # return data_
|
||
# # #
|
||
# # # data_all = []
|
||
# # #
|
||
# # # for i, data in enumerate(in_seq(tst)):
|
||
# # # if i % 2 == 0:
|
||
# # # data_all.append(data + "\n")
|
||
# # # else:
|
||
# # # my_sequence = Seq(data)
|
||
# # # data_all.append(str(my_sequence.reverse_complement())+"\n")
|
||
# # # return "".join(data_all)
|
||
# #
|
||
#
|
||
# url = ''
|
||
#
|
||
#
|
||
# class Tool(object):
|
||
# def __init__(self):
|
||
# self.jg = {
|
||
# 'Basics': {},
|
||
# 'senior': {},
|
||
# }
|
||
#
|
||
# def ex_file(self, file_name):
|
||
# self.jg["ex_file"] = url + file_name
|
||
#
|
||
# def Basics(self, title, option, label, vale):
|
||
#
|
||
# if self.jg["Basics"].get(title):
|
||
# self.jg["Basics"][title].append({'name': option, 'data': label, 'vale': vale})
|
||
# else:
|
||
# self.jg["Basics"][title] = [{'name': option, 'data': label, 'vale': vale}]
|
||
#
|
||
# def Senior(self, title, option, label, vale):
|
||
#
|
||
# if self.jg["senior"].get(title):
|
||
# self.jg["senior"][title].append({'name': option, 'data': label, 'vale': vale})
|
||
# else:
|
||
# self.jg["senior"][title] = [{'name': option, 'data': label, 'vale': vale}]
|
||
#
|
||
# def row_back(self, lable, value):
|
||
# return f"""
|
||
# <dd style="overflow: hidden">
|
||
# <div class="color">
|
||
# <label class="label_meg">{lable} </label>
|
||
# <div class="layui-input-inline" style="float: right">
|
||
# <input type="text" id="{lable}" lay-verify="required" value="{value}"
|
||
# autocomplete="off" class="layui-input"
|
||
# style="height: 25px; width:100px;margin-top: 6px">
|
||
# </div>
|
||
# </div>
|
||
# </dd>
|
||
# """
|
||
#
|
||
# def head_back(self, title):
|
||
# return f"""
|
||
# <dd style="overflow: hidden">
|
||
# <div class="color">
|
||
# <label class="label_meg" style="font-size: 20px">{title} </label>
|
||
# </div>
|
||
# </dd>
|
||
# """
|
||
#
|
||
# def back_(self, sort):
|
||
# tmp = []
|
||
# for i in self.jg[sort].keys():
|
||
# tmp.append(self.head_back(i))
|
||
# for j in self.jg[sort][i]:
|
||
# tmp.append(self.row_back(j["data"], j['vale']))
|
||
# return '\n'.join(tmp)
|
||
#
|
||
# def html_out(self):
|
||
# print("基础------->")
|
||
# print(self.back_("Basics"))
|
||
# print('高级------->')
|
||
# print(self.back_("senior"))
|
||
#
|
||
# def js_out(self):
|
||
# js_list = []
|
||
# all_dict = dict(self.jg["Basics"], **self.jg["senior"])
|
||
# for i in all_dict.keys():
|
||
# for j in all_dict[i]:
|
||
# js_list.append(f'{j["data"]}: (document.getElementById("{j["data"]}").value),')
|
||
#
|
||
# print("\n".join(js_list))
|
||
#
|
||
# def view_out(self):
|
||
# py_list = []
|
||
# all_dict = dict(self.jg["Basics"], **self.jg["senior"])
|
||
# for i in all_dict.keys():
|
||
# for j in all_dict[i]:
|
||
# py_list.append(f'{j["data"]} = request.GET.get("{j["data"]}", "{j["vale"]}")')
|
||
#
|
||
# print("\n".join(py_list))
|
||
#
|
||
# on_num = ' oninput = "value=value.replace(/[^\d]/g,'').slice(0,3)" '
|
||
#
|
||
# def html_out(data):
|
||
# all_list = []
|
||
# for i in data:
|
||
# title = f"""
|
||
# <dd style="overflow: hidden">
|
||
# <div class="color">
|
||
# <label class="label_meg">{i['title']} </label>
|
||
# </div>
|
||
# </dd>
|
||
# """
|
||
# all_list.append(title)
|
||
#
|
||
# for j in i['data']:
|
||
# code = f"""
|
||
# <dd style="overflow: hidden">
|
||
# <div class="color">
|
||
# <label class="label_meg">{j['name']} </label>
|
||
# <div class="layui-input-inline" style="float: right">
|
||
# <input {j['astrict']} type="text" id="{j['name']}" lay-verify="required" value="{j['value']}"
|
||
# autocomplete="off" class="layui-input"
|
||
# style="height: 25px; width:100px;margin-top: 6px">
|
||
# </div>
|
||
# </div>
|
||
# </dd>
|
||
# """
|
||
# all_list.append(code)
|
||
#
|
||
# return all_list
|
||
#
|
||
#
|
||
# def js_out(data):
|
||
# all_list = []
|
||
# new_list = data["Basics"] + data["senior"]
|
||
# for i in new_list:
|
||
# for j in i['data']:
|
||
# all_list.append(f'{j["name"]}: (document.getElementById("{j["name"]}").value),')
|
||
#
|
||
# return "\n".join(all_list)
|
||
#
|
||
#
|
||
# def py_out(data):
|
||
# all_list = []
|
||
# new_list = data["Basics"] + data["senior"]
|
||
# for i in new_list:
|
||
# for j in i['data']:
|
||
# all_list.append(f'{j["name"]}: (document.getElementById("{j["name"]}").value),')
|
||
# return "\n".join(all_list)
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
#
|
||
# data = {
|
||
# 'Basics': [{'title': 'lable', 'data': [
|
||
# {'name': 'x_name', "value": 'x', 'astrict': ''},
|
||
# {'name': 'x_name', "value": 'x', 'astrict': ''},
|
||
# {'name': 'x_col', "value": 'x_col', 'astrict': ''},
|
||
# {'name': 'x_col', "value": 'x_col', 'astrict': ''},
|
||
# ]},
|
||
# {'title': 'title', 'data': [
|
||
# {'name': 'title', "value": 'title', 'astrict': ''},
|
||
# {'name': 'title_size', "value": '12',
|
||
# 'astrict': ' oninput = "value=value.replace(/[^\d]/g,'').slice(0,2)" '},
|
||
# ]},
|
||
# {'title': 'data', 'data': [
|
||
# {'name': 'range_column', "value": 'range_column', 'astrict': ''},
|
||
# {'name': 'range_data', "value": '1-2', 'astrict': ''},
|
||
# ]},
|
||
#
|
||
# ],
|
||
#
|
||
# 'Senior': [{'title': 'lable', 'data': [
|
||
# {'name': 'xticks', "value": '0', 'astrict': on_num},
|
||
# {'name': 'yticks', "value": '0', 'astrict': on_num}]
|
||
# }]
|
||
# }
|
||
#
|
||
#
|
||
|
||
|
||
a = "font_color, x_color, x_axis_color, y_color, y_axis_color, line_color, color, line_color_bar, color_bar, y_color_bar, y_axis_color_bar, x_axis_color_bar, background"
|
||
|
||
a = a.split(",")
|
||
for i in a:
|
||
i = i.strip()
|
||
print(f"{{'name': '{i}', 'value': '', 'astrict': ''}},")
|