From ef55699ca6bc6a14d4bf17b34d758d835cb330b7 Mon Sep 17 00:00:00 2001 From: fy3047957834 <3047957834@qq.com> Date: Sun, 26 Sep 2021 15:55:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=AE=8C=E6=88=90=EF=BC=8C=E6=80=BB=E8=AE=A1?= =?UTF-8?q?96=E4=B8=AA=EF=BC=8C=E5=88=A0=E9=99=A42=E4=B8=AA=EF=BC=8C11?= =?UTF-8?q?=E4=B8=AA=E6=9C=AA=E8=BF=90=E8=A1=8C=E6=88=90=E5=8A=9F=E6=88=96?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=BC=82=E5=B8=B8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart/charts.py | 684 ++++++++++++++++++++++++++++++------------------ chart/tools.py | 4 +- db.sqlite3 | Bin 745472 -> 745472 bytes 3 files changed, 426 insertions(+), 262 deletions(-) diff --git a/chart/charts.py b/chart/charts.py index 587964f..35378d9 100644 --- a/chart/charts.py +++ b/chart/charts.py @@ -12,7 +12,8 @@ def keep_txt_to_file(code, script_path): f.write(code) -def scatter_plot(file_path, chart_out_path, out_path, x_scale_font_angle, y_scale_font_angle, x_column_name, y_column_name, group_by_column='category', x_name="x", y_name="y", +def scatter_plot(file_path, chart_out_path, out_path, x_scale_font_angle, y_scale_font_angle, x_column_name, + y_column_name, group_by_column='category', x_name="x", y_name="y", title="chart", dpi=100, width=10, height=6, title_font_size=12, ): midwest = pd.read_csv(file_path) # 导入文件 @@ -58,7 +59,8 @@ def scatter_plot(file_path, chart_out_path, out_path, x_scale_font_angle, y_scal plt.savefig(f"{out_path}.pdf") -def Each_regression_line_in_its_own_column(file_path, chart_out_path, out_path, group_by_column, group_by_range, x_column_name, y_column_name, +def Each_regression_line_in_its_own_column(file_path, chart_out_path, out_path, group_by_column, group_by_range, + x_column_name, y_column_name, title, title_font_size, x_name, y_name, color): df = pd.read_csv(file_path) group_by_range = [group_by_range.split("-")[0], group_by_range.split("-")[1]] @@ -705,7 +707,8 @@ def Dumbbell_Plot(file_path, chart_out_path, out_path, column_name_1, column_nam def Stacked_Histogram_for_Continuous_Variable(file_path, chart_out_path, out_path, x_column_name, group_by_column, - title, title_font_size, x_scale_font_angle, y_scale_font_angle, x_name, y_name): + title, title_font_size, x_scale_font_angle, y_scale_font_angle, x_name, + y_name): df = pd.read_csv(file_path) # Prepare data @@ -753,7 +756,8 @@ def Stacked_Histogram_for_Continuous_Variable(file_path, chart_out_path, out_pat # 测试文件 mpg.csv # 基础参数 图片的长/宽/分辨率/字号/x轴字号/标题的字号、xy轴限制/颜色 -def Density_Plot(file_path, chart_out_path, x_scale_font_angle, y_scale_font_angle, y_name, x_name, y_font_size, x_font_size, out_path, +def Density_Plot(file_path, chart_out_path, x_scale_font_angle, y_scale_font_angle, y_name, x_name, y_font_size, + x_font_size, out_path, scale_font_size, title, title_font_size, column_name): df = pd.read_csv(file_path) @@ -801,7 +805,8 @@ def Density_Plot(file_path, chart_out_path, x_scale_font_angle, y_scale_font_ang # 测试文件 mpg.csv # 基础参数 图片的长/宽/分辨率/字号/x轴字号/标题的字号、xy轴限制/颜色 -def Joy_Plot(file_path, chart_out_path, out_path, title, title_font_size, x_scale_font_angle, y_scale_font_angle, y_name, x_name, column_name_1, column_name_2, +def Joy_Plot(file_path, chart_out_path, out_path, title, title_font_size, x_scale_font_angle, y_scale_font_angle, + y_name, x_name, column_name_1, column_name_2, group_by_column, y_scale_limit): mpg = pd.read_csv(file_path) @@ -835,7 +840,8 @@ def Joy_Plot(file_path, chart_out_path, out_path, title, title_font_size, x_scal # 基础参数 图片的长/宽/分辨率/字号/x轴字号/标题的字号、xy轴限制/颜色 def boxplot(file_path, chart_out_path, out_path, - scale_font_size, title, title_font_size, font_size, font_color, y_scale_min, y_scale_max, x_column_name, y_column_name, x_scale_font_angle, y_scale_font_angle, y_name, x_name, color): + scale_font_size, title, title_font_size, font_size, font_color, y_scale_min, y_scale_max, x_column_name, + y_column_name, x_scale_font_angle, y_scale_font_angle, y_name, x_name, color): df = pd.read_csv(file_path) # Draw Plot plt.figure(figsize=(9.4, 4.25), dpi=180) @@ -887,7 +893,8 @@ def boxplot(file_path, chart_out_path, out_path, def Dot_Box_Plot(file_path, chart_out_path, out_path, - title, title_font_size, point_size, line_color, x_scale_font_angle, y_scale_font_angle, y_name, x_name, x_column_name, y_column_name, group_by_column, legend_name, color): + title, title_font_size, point_size, line_color, x_scale_font_angle, y_scale_font_angle, y_name, x_name, + x_column_name, y_column_name, group_by_column, legend_name, color): df = pd.read_csv(file_path) plt.figure(figsize=(9.4, 4.25), dpi=180) sns.boxplot( @@ -928,7 +935,8 @@ def Dot_Box_Plot(file_path, chart_out_path, out_path, def Violin_Plot(file_path, chart_out_path, out_path, - title, title_font_size, x_column_name, y_column_name, x_scale_font_angle, y_scale_font_angle, y_name, x_name, color): + title, title_font_size, x_column_name, y_column_name, x_scale_font_angle, y_scale_font_angle, y_name, + x_name, color): df = pd.read_csv(file_path) # Draw Plot @@ -962,7 +970,8 @@ def Violin_Plot(file_path, chart_out_path, out_path, def Population_Pyramid(file_path, chart_out_path, out_path, - title, title_font_size, x_name, y_name, group_by_column, x_scale_font_angle, y_scale_font_angle, y_column_name, x_column_name): + title, title_font_size, x_name, y_name, group_by_column, x_scale_font_angle, y_scale_font_angle, + y_column_name, x_column_name): df = pd.read_csv(file_path) # Draw Plot @@ -1003,7 +1012,8 @@ def Population_Pyramid(file_path, chart_out_path, out_path, # 测试文件 mpg.csv -def Waffle_Chart(file_path, chart_out_path, out_path, rows_number, group_by_column, x_scale_font_angle, y_scale_font_angle, y_name, x_name, +def Waffle_Chart(file_path, chart_out_path, out_path, rows_number, group_by_column, x_scale_font_angle, + y_scale_font_angle, y_name, x_name, title_font_size, title): df_raw = pd.read_csv(file_path) @@ -1104,7 +1114,8 @@ def Treemap(file_path, chart_out_path, out_path, title, group_by_column, title_f # 测试文件 mpg.csv -def Bar_Chart(file_path, chart_out_path, out_path, title, title_font_size, font_size, y_scale_min, y_scale_max, width, group_by_column, x_scale_font_angle, +def Bar_Chart(file_path, chart_out_path, out_path, title, title_font_size, font_size, y_scale_min, y_scale_max, width, + group_by_column, x_scale_font_angle, y_scale_font_angle, y_name, x_name): import random df_raw = pd.read_csv(file_path) @@ -1153,7 +1164,8 @@ def Bar_Chart(file_path, chart_out_path, out_path, title, title_font_size, font_ def Time_Series_Plot(file_path, chart_out_path, out_path, - polt_color, title, title_font_size, x_column, y_column, x_font_size, y_font_size, y_scale_min, y_scale_max, x_scale_font_angle, + polt_color, title, title_font_size, x_column, y_column, x_font_size, y_font_size, y_scale_min, + y_scale_max, x_scale_font_angle, y_scale_font_angle, y_name, x_name): df = pd.read_csv(file_path) @@ -1196,7 +1208,8 @@ def Time_Series_Plot(file_path, chart_out_path, out_path, # 测试文件 mortality.csv def Multiple_Time_Series(file_path, chart_out_path, out_path, - font_size, title, title_font_size, x_font_size, y_font_size, x_scale_min, x_scale_max, x_scale_font_angle, y_scale_font_angle, y_name, + font_size, title, title_font_size, x_font_size, y_font_size, x_scale_min, x_scale_max, + x_scale_font_angle, y_scale_font_angle, y_name, x_name): df = pd.read_csv(file_path) @@ -1270,8 +1283,10 @@ def Multiple_Time_Series(file_path, chart_out_path, out_path, # 测试文件 economics.csv def Plotting_with_different_scales_using_secondary_Y_axis(file_path, chart_out_path, out_path, - x_name, x_font_size, y_name_1, y_font_size_1, y_font_color_1, y_name_2, y_font_size_2, - y_font_color_2, title, title_font_size, x_column, y_column_1, y_column_2, x_scale_font_angle, + x_name, x_font_size, y_name_1, y_font_size_1, y_font_color_1, + y_name_2, y_font_size_2, + y_font_color_2, title, title_font_size, x_column, y_column_1, + y_column_2, x_scale_font_angle, y_scale_font_angle): df = pd.read_csv(file_path) @@ -1320,7 +1335,8 @@ def Plotting_with_different_scales_using_secondary_Y_axis(file_path, chart_out_p # 测试文件 nightvisitors.csv def Stacked_Area_Chart(file_path, chart_out_path, out_path, - y_scale_min, y_scale_max, title, title_font_size, data_column, x_scale_font_angle, y_scale_font_angle, y_name, x_name): + y_scale_min, y_scale_max, title, title_font_size, data_column, x_scale_font_angle, + y_scale_font_angle, y_name, x_name): df = pd.read_csv(file_path) # Decide Colors @@ -1380,7 +1396,8 @@ def Stacked_Area_Chart(file_path, chart_out_path, out_path, # 测试文件 economics.csv def Area_Chart_UnStacked(file_path, chart_out_path, out_path, - y_scale_min, y_scale_max, title, title_font_size, x_column, y_column_1, y_column_2, x_scale_font_angle, y_scale_font_angle, y_name, x_name): + y_scale_min, y_scale_max, title, title_font_size, x_column, y_column_1, y_column_2, + x_scale_font_angle, y_scale_font_angle, y_name, x_name): df = pd.read_csv(file_path) # Prepare Data @@ -1472,10 +1489,11 @@ def Dendrogram(file_path, chart_out_path, out_path, # 冯洋 # 基础参数 file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Composition_Bar.csv -def Composition_Bar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Composition_Bar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): code = f""" @@ -1524,9 +1542,11 @@ dev.off() def Composition_BarOfColorsDataByGroup(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color, legend_name, legend_position): file_path = file_path.replace("\\", "\\\\") @@ -1550,7 +1570,7 @@ gg <- g + geom_bar(aes(fill=y), width = 0.5) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -1578,12 +1598,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 Composition_Pie.csv -def Composition_Pie(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Composition_Pie(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, + legend_position): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -1606,7 +1628,7 @@ pie <- ggplot(df, aes(x = "", y=freq, fill = factor(class))) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -1636,12 +1658,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 Composition_Pie.csv def Composition_Waffles(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, color): + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -1670,7 +1694,7 @@ gg <- ggplot(df, aes(x = x, y = y, fill = category)) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -1698,12 +1722,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, model2, model3, model4, model5 +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, model2, model3, model4, model5 # 实例文件 Correlation_Box.csv -def Correlation_Box(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, - y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, model1, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, model2, model3, model4, +def Correlation_Box(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, + y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, model1, + legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, model2, + model3, model4, model5): code_1 = """ggMarginal(gg, type = "histogram", fill="transparent")""" code_2 = """ggMarginal(gg, type = "density", fill="transparent")""" @@ -1734,7 +1761,7 @@ gg <- ggplot(datas, aes(x, y)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -1777,12 +1804,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Correlation_Bubble.csv def Correlation_Bubble(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, size_legend_name, legend_name, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, size_legend_name, legend_name, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): code = f""" datas <- read.csv("{file_path}") @@ -1806,7 +1834,7 @@ g <- ggplot(datas, aes(y, z)) + y="{y_name}", col="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -1835,12 +1863,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Correlation_Correlation.csv -def Correlation_Correlation(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): +def Correlation_Correlation(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, + title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): code = f""" datas <- read.csv("{file_path}") @@ -1865,7 +1895,6 @@ gg <- ggcorrplot(corr, hc.order = TRUE, x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -1890,12 +1919,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Correlation_Count.csv -def Correlation_Count(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Correlation_Count(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -1918,7 +1948,7 @@ gg <- ggplot(datas, aes(x, y)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -1943,14 +1973,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Correlation_Jitter.csv def Correlation_Jitter(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): - legend, legend_name, legend_position = "", "", "" - + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, legend_name, legend_position, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -1974,7 +2003,6 @@ gg <- g + geom_jitter(width = .5, size=1) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2002,12 +2030,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Correlation_Scatter.csv def Correlation_Scatter(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, size_legend_name, legend_name, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, size_legend_name, legend_name, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2041,7 +2070,7 @@ gg <- ggplot(datas, aes(x=y, y=z)) + col="{legend_name}", size="{size_legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -2066,12 +2095,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Deviation_Area.csv -def Deviation_Area(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Deviation_Area(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2103,7 +2133,6 @@ gg <- ggplot(datas, aes(x, returns_perc)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -2128,12 +2157,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Deviation_Bar.csv -def Deviation_Bar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, - y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, type_1, type_2, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): +def Deviation_Bar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, + y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, type_1, + type_2, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2164,7 +2195,7 @@ gg <- ggplot(datas, aes(x, z, label=z)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -2189,12 +2220,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Deviation_Dots.csv -def Deviation_Dots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, - y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, type_1, type_2, x_font_color, y_font_color, - x_scale_font_color, y_scale_font_color, title_font_color, background_color): +def Deviation_Dots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, + y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, type_1, + type_2, x_font_color, y_font_color, + x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2212,7 +2245,7 @@ def Deviation_Dots(file_path, chart_out_path, out_path, title, caption, subtitle # Plot gg <- ggplot(datas, aes(x, y, label=y)) + geom_point(stat='identity', aes(col=z), size=6) + - scale_font_color_manual( + scale_color_manual( labels = c("{type_1}", "{type_2}"), values = c("{type_1}"="#00ba38", "{type_2}"="#f8766d")) + geom_text(color="white", size=2) + @@ -2224,7 +2257,7 @@ def Deviation_Dots(file_path, chart_out_path, out_path, title, caption, subtitle x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -2249,12 +2282,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Deviation_Lollipop.csv def Deviation_Lollipop(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2283,9 +2317,8 @@ gg <- ggplot(datas, aes(x, y, label=y)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), - axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), - axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) + axis.text.x=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}), + axis.title.x=element_text(size={y_font_size}, color="{y_font_color}"), axis.title.y=element_text(size={x_font_size}, color="{x_font_color}")) png("{chart_out_path}",width=900,height=408) plot(gg) @@ -2308,12 +2341,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, line_color, point_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, line_color, point_color # 实例文件 Distribution_BoxWithDots.csv -def Distribution_BoxWithDots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, +def Distribution_BoxWithDots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, + title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, line_color, point_color): file_path = file_path.replace("\\", "\\\\") @@ -2342,7 +2378,7 @@ gg <- g + geom_boxplot(color="{line_color}") + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2370,12 +2406,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, line_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, line_color # 实例文件 Distribution_Box_1.csv def Distribution_Box_1(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, line_color): + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + line_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2420,12 +2458,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, line_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, line_color # 实例文件 Distribution_Box_2.csv def Distribution_Box_2(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, line_color): file_path = file_path.replace("\\", "\\\\") @@ -2450,7 +2490,7 @@ gg <- g + geom_boxplot(aes(fill=factor(z)), color="{line_color}") + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2478,13 +2518,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, line_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, line_color # 实例文件 Distribution_DensityFunction.csv def Distribution_DensityFunction(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, line_color): file_path = file_path.replace("\\", "\\\\") @@ -2507,7 +2549,7 @@ gg <- g + geom_density(aes(fill=factor(y)), alpha=0.8, color="{line_color}") + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2535,12 +2577,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, model +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, model # 实例文件 Distribution_Histogram.csv -def Distribution_Histogram(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, model, x_font_color, - y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, color): +def Distribution_Histogram(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, + title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, model, x_font_color, + y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, + legend_position, color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2578,7 +2623,7 @@ def Distribution_Histogram(file_path, chart_out_path, out_path, title, caption, y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2606,14 +2651,16 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 Distribution_HistogramOfClassificationVariables.csv def Distribution_HistogramOfClassificationVariables(file_path, chart_out_path, out_path, title, caption, subtitle, - x_name, y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, + x_name, y_name, title_font_size, x_font_size, y_font_size, + x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, - background_color, legend_name, legend_position): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color, + legend_name, legend_position): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2636,7 +2683,7 @@ gg <- g + geom_bar(aes(fill=y), width = 0.5) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2664,14 +2711,11 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, color # 实例文件 Distribution_PopulationPyramid.csv def Distribution_PopulationPyramid(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, - legend_position, color): + legend, legend_name, color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2704,11 +2748,7 @@ labs(title="{title}", caption="{caption}", x="{x_name}", y="{y_name}", - fill="{legend_name}") + - theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), - axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), - legend.position="{legend_position}") + + fill="{legend_name}")+ theme_tufte() + # Tufte theme from ggfortify theme(plot.title = element_text(hjust = .5), axis.ticks = element_blank()) + # Centre plot title @@ -2737,12 +2777,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, color # 实例文件 Distribution_TufteBox.csv -def Distribution_TufteBox(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, +def Distribution_TufteBox(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, + title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, color): file_path = file_path.replace("\\", "\\\\") @@ -2768,7 +2811,7 @@ gg <- g + geom_tufteboxplot(color="{color}") + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2796,12 +2839,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, line_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position, line_color # 实例文件 Distribution_Violin.csv def Distribution_Violin(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, - x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_scale_font_angle, legend, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position, line_color): file_path = file_path.replace("\\", "\\\\") @@ -2824,7 +2869,7 @@ gg <- g + geom_violin(color="{line_color}") + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2854,7 +2899,7 @@ dev.off() # 基础参数 file_path, chart_out_path, out_path, title, caption, subtitle, title_font_size, -# 高级参数 title_font_color, background_color +# 高级参数 title_font_color # 实例文件 Group_HierarchicalTree.csv def Group_HierarchicalTree(file_path, chart_out_path, out_path, title, caption, subtitle, title_font_size, @@ -2897,12 +2942,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 Sort_Dots.csv -def Sort_Dots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, y_font_size, +def Sort_Dots(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, + legend_position): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2933,7 +2980,7 @@ gg <- ggplot(datas, aes(x, y, fill=x)) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -2961,12 +3008,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, species_1, species_2 +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, species_1, species_2 # 实例文件 Sort_Lean.csv -def Sort_Lean(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, y_font_size, +def Sort_Lean(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, time_1, time_2, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, species_1, species_2): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, species_1, + species_2): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -2990,7 +3039,7 @@ g <- ggplot(df) + show.legend=F) + geom_vline(xintercept=1, linetype="dashed", size=.1) + geom_vline(xintercept=2, linetype="dashed", size=.1) + - scale_font_color_manual(labels = c("Up", "Down"), + scale_color_manual(labels = c("Up", "Down"), values = c("green"="#00ba38", "red"="#f8766d")) + labs(title="{title}", @@ -2999,7 +3048,7 @@ g <- ggplot(df) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) + xlim(.5, 2.5) + ylim(0,(1.1*(max(df$`{time_1}`, df$`{time_2}`)))) @@ -3015,8 +3064,7 @@ g <- g + geom_text(label="{species_2}", x=2, y=1.1*(max(df$`{time_1}`, df$`{time_2}`)), hjust=-0.1, size=5) # Minify theme -gg <- g + theme(panel.background_color = element_blank(), - panel.grid = element_blank(), +gg <- g + theme(panel.grid = element_blank(), axis.ticks = element_blank(), axis.text.x = element_blank(), panel.border = element_blank(), @@ -3043,12 +3091,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 Sort_Lollipop.csv -def Sort_Lollipop(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Sort_Lollipop(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, + legend_position): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3075,7 +3125,7 @@ gg <- ggplot(datas, aes(x, y, fill=x)) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -3103,14 +3153,19 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 Sort_OrderedBar.csv -def Sort_OrderedBar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, x_font_size, +def Sort_OrderedBar(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, title_font_size, + x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") + x_name = x_name.replace(' ', '_') + + y_name = y_name.replace(' ', '_') + code = f""" datas <- read.csv("{file_path}") @@ -3119,7 +3174,7 @@ x <- datas[,1] y <- datas[,2] df <- aggregate(y, by=list(x), FUN=mean) -colnames(df) <- c("{x_name}", "{y_name}") +colnames(df) <- c("{x_name}", "{y_name}") df <- df[order(df${y_name}), ] df${x_name} <- factor(df${x_name}, levels = df${x_name}) library(ggplot2) @@ -3134,7 +3189,6 @@ gg <- ggplot(df, aes(x={x_name}, y={y_name}, fill={x_name})) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -3159,13 +3213,14 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_Accumulation.csv def TemporalChanges_Accumulation(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, type_1, type_2, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3201,7 +3256,7 @@ gg <- ggplot(datas, aes(x)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -3226,13 +3281,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, legend_position +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, legend_name, legend_position # 实例文件 TemporalChanges_CalendarHeat.csv def TemporalChanges_CalendarHeat(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, legend, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color, legend_name, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, + legend_name, legend_position): file_path = file_path.replace("\\", "\\\\") @@ -3277,7 +3334,7 @@ gg <- ggplot(df, aes(monthweek, v, fill = y)) + y="{y_name}", fill="{legend_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}"), legend.position="{legend_position}") @@ -3305,13 +3362,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_DataframeTimeSeries.csv def TemporalChanges_DataframeTimeSeries(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3335,7 +3394,6 @@ gg <- ggplot(datas, aes(x)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -3360,13 +3418,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_SeasonalTimeSeries.csv def TemporalChanges_SeasonalTimeSeries(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, time, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color): time = time.split("-") time = (int(time[0]), int(time[1])) @@ -3390,7 +3450,7 @@ gg <-ggseasonplot(datas) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -3415,14 +3475,16 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_ShowMultipleTimeSeriesSimultaneously.csv def TemporalChanges_ShowMultipleTimeSeriesSimultaneously(file_path, chart_out_path, out_path, title, caption, subtitle, - x_name, y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, - y_scale_font_size, x_scale_font_angle, y_scale_font_angle, type_1, type_2, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, - background_color): + x_name, y_name, title_font_size, x_font_size, y_font_size, + x_scale_font_size, + y_scale_font_size, x_scale_font_angle, y_scale_font_angle, + type_1, type_2, + x_font_color, y_font_color, x_scale_font_color, + y_scale_font_color, title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3454,11 +3516,11 @@ def TemporalChanges_ShowMultipleTimeSeriesSimultaneously(file_path, chart_out_pa y="{y_name}", color=NULL) + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) + # title and caption scale_x_date(labels = lbls, breaks = brks) + - scale_font_color_manual(labels = c("{type_1}", "{type_2}"), + scale_color_manual(labels = c("{type_1}", "{type_2}"), values = c("{type_1}"="#00ba38", "{type_2}"="#f8766d")) + theme(panel.grid.minor = element_blank()) @@ -3484,12 +3546,13 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_TimeSeries.csv def TemporalChanges_TimeSeries(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, y_name, - title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, y_scale_font_angle, time, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, + x_scale_font_angle, y_scale_font_angle, time, + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color): time = time.split("-") time = (int(time[0]), int(time[1])) @@ -3513,7 +3576,7 @@ gg <- autoplot(datas) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) @@ -3538,13 +3601,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_TimeSeriesOfAnnualData.csv def TemporalChanges_TimeSeriesOfAnnualData(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, - y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, + y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3573,7 +3638,7 @@ gg <- ggplot(datas, aes(x)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) + # title and caption scale_x_date(labels = lbls, @@ -3601,13 +3666,15 @@ dev.off() os.system(f"Rscript {out_path}.R") -# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color +# 高级参数 x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color # 实例文件 TemporalChanges_TimeSeriesOfMonthlyData.csv def TemporalChanges_TimeSeriesOfMonthlyData(file_path, chart_out_path, out_path, title, caption, subtitle, x_name, - y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, y_scale_font_size, x_scale_font_angle, + y_name, title_font_size, x_font_size, y_font_size, x_scale_font_size, + y_scale_font_size, x_scale_font_angle, y_scale_font_angle, - x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, title_font_color, background_color): + x_font_color, y_font_color, x_scale_font_color, y_scale_font_color, + title_font_color): file_path = file_path.replace("\\", "\\\\") code = f""" @@ -3636,7 +3703,7 @@ gg <- ggplot(datas, aes(x)) + x="{x_name}", y="{y_name}") + theme(title=element_text(size={title_font_size}, color="{title_font_color}"), - plot.background_color = element_rect(fill="{background_color}", color="{background_color}"), + axis.text.x=element_text(color="{x_scale_font_color}", size={x_scale_font_size}, angle={x_scale_font_angle}, vjust=0.6), axis.text.y=element_text(color="{y_scale_font_color}", size={y_scale_font_size}, angle={y_scale_font_angle}), axis.title.x=element_text(size={x_font_size}, color="{x_font_color}"), axis.title.y=element_text(size={y_font_size}, color="{y_font_color}")) + # title and caption scale_x_date(labels = lbls, @@ -3669,7 +3736,8 @@ dev.off() # 高级参数 title_font_color, scale_font_color, line_color, font_color, heading_font_color # 示例文件 Aggregated_Pyramids.xlsx -def Aggregated_Pyramids(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, scale_font_size, font_size, +def Aggregated_Pyramids(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, scale_font_size, + font_size, heading_1, heading_2, heading_font_size, title_font_color, scale_font_color, line_color, font_color, heading_font_color): code = f""" @@ -3800,9 +3868,17 @@ def Aggregated_Pyramids(file_path, char_out_path, out_path, title, caption, subt # 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, line_color, color # 示例文件 Areas_Under_a_Time_Series.csv -def Areas_Under_a_Time_Series(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, - x_scale_font_size, y_name, y_font_size, y_scale_font_size, event_1, event_2, event_3, font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, line_color, color): +def Areas_Under_a_Time_Series(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, + x_font_size, + x_scale_font_size, y_name, y_font_size, y_scale_font_size, event_1, event_2, event_3, + font_size, + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + font_color, line_color, color): + + font_color = font_color[4:-1] + + color = color[4:-1] + code = f""" library(gdata) colour<-rgb({font_color},150,maxColorValue=255) @@ -3931,7 +4007,7 @@ def Balloon_Plot(file_path, char_out_path, out_path, title, caption_1, caption_2 myColours[i] <- if(myData$Survived[i] == "Yes") "{color_1}" else "{color_2}" pdf("{out_path}.pdf") - par(omi=c(0.75,0.25,0.5,0.25),mai=c(0.25,0.55,0.25,0),cex={font_size}) + par(omi=c(0.75,0.25,0.5,0.25),mai=c(0.25,0.55,0.25,0),cex={font_size}) balloonplot(x=list(Age,Sex),main="", y=list(Class=Class, Survived=gdata::reorder.factor(Survived,new.order=c(2,1))), @@ -4012,16 +4088,21 @@ def Balloon_Plot(file_path, char_out_path, out_path, title, caption_1, caption_2 f"Rscript {out_path}.R") # 基础参数 file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, image_name_font_size, mark_country_1, mark_country_2, average_font_size -# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, image_name_font_color, background_color, average_font_color, mark_color, color +# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, image_name_font_color, average_font_color, mark_color, color # 示例文件 Bar_Chart_Simple.xlsx def Bar_Chart_Simple(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, image_name_font_size, mark_country_1, mark_country_2, average_font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, image_name_font_color, background_color, + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + image_name_font_color, background_color, average_font_color, mark_color, color): y_name = "\n".join(y_name) + background_color = background_color[4:-1] + + mark_color = mark_color[4:-1] + code = f""" library(gdata) ipsos<-read.xls('{file_path}',encoding="latin1") @@ -4238,7 +4319,7 @@ def Bump_Chart(file_path, char_out_path, out_path, title, caption, subtitle, tit axis(4,col=par("bg"),col.ticks="{mark_scale_font_color}",col.axis="{mark_scale_font_color}",lwd.ticks=0.5,tck=-0.025,at=z1[5,2],round(z1[5,2]/1000, digits=1),cex.axis={scale_font_size}) dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(0.5,0.5,0.9,0.5),mai=c(0,0.75,0.25,0.75),xpd=T,las=1,col="{font_color}") bumpchart(z1,rank=F,pch=18,top.labels=c("",""),col=myColours,lwd=myLineWidth,mar=c(2,12,1,12),cex=1.1) @@ -4284,7 +4365,8 @@ def Bump_Chart(file_path, char_out_path, out_path, title, caption, subtitle, tit def Column_Chart_for_Developments(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, high_color, low_color): + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + high_color, low_color): y_name = "\n".join(y_name) code = f""" @@ -4326,7 +4408,7 @@ def Column_Chart_for_Developments(file_path, char_out_path, out_path, title, cap mtext("{y_name}",4,line=0,adj=0.5,cex={y_font_size},font=3,outer=T,col="{y_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(las=1,cex=0.9,omi=c(0.75,0.25,1.25,0.25),mai=c(0.5,0.25,0.5,0.75),las=1) barplot(myData,border=NA,col=myColours,names.arg=substr(myLabels,3,4),axes=F,col.axis="{x_scale_font_color}",cex.names={x_scale_font_size}) abline(h=c(10,20,30,40,50,60,70,80),col=par("bg"),lwd=1.5) @@ -4369,9 +4451,11 @@ def Column_Chart_for_Developments(file_path, char_out_path, out_path, title, cap # 示例文件 Column_Chart_with_Percentages_for_Growth_Developments.csv def Column_Chart_with_Percentages_for_Growth_Developments(file_path, char_out_path, out_path, title, caption, subtitle, - title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, + title_font_size, x_name, x_font_size, x_scale_font_size, + y_name, y_font_size, y_scale_font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + title_font_color, x_font_color, x_scale_font_color, + y_font_color, y_scale_font_color, color, high_color, low_color): code = f""" datas <- read.csv("{file_path}") @@ -4477,7 +4561,7 @@ def Column_Chart_with_Percentages_for_Growth_Developments(file_path, char_out_pa mtext("{x_name}",1,line=0,adj=0.5,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(las=1,cex=0.9,omi=c(0.75,0.5,1.25,0.5),mai=c(0.5,1,0,1),las=1) # Define data @@ -4586,9 +4670,11 @@ def Column_Chart_with_Percentages_for_Growth_Developments(file_path, char_out_pa # 示例文件 Comparison_with_Bar_Chart_1.xlsx def Comparison_with_Bar_Chart_1(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, - x_font_size, x_scale_font_size, y_scale_font_size, ruler_name, ruler_name_font_size, ruler_number_font_size, + x_font_size, x_scale_font_size, y_scale_font_size, ruler_name, ruler_name_font_size, + ruler_number_font_size, max_number_size, - title_font_color, x_font_color, x_scale_font_color, max_number_font_color, y_scale_font_color, color_1, color_2, + title_font_color, x_font_color, x_scale_font_color, max_number_font_color, + y_scale_font_color, color_1, color_2, zero_graduation_color, ruler_color): code = f""" library(fBasics) @@ -4710,10 +4796,13 @@ def Comparison_with_Bar_Chart_1(file_path, char_out_path, out_path, title, capti # 示例文件 Comparison_with_Bar_Chart_2.xlsx def Comparison_with_Bar_Chart_2(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, - x_font_size, x_scale_font_size, y_scale_font_size, ruler_name, max_number_size, ruler_name_font_size, - ruler_number_font_size, country_1, country_2, country_3, country_1_time_1, country_1_time_2, + x_font_size, x_scale_font_size, y_scale_font_size, ruler_name, max_number_size, + ruler_name_font_size, + ruler_number_font_size, country_1, country_2, country_3, country_1_time_1, + country_1_time_2, country_2_time_1, country_2_time_2, country_3_time_1, country_3_time_2, - title_font_color, x_font_color, x_scale_font_color, ruler_color, y_scale_font_color, zero_graduation_color, + title_font_color, x_font_color, x_scale_font_color, ruler_color, y_scale_font_color, + zero_graduation_color, color_1, color_2, max_number_font_color, ruler_number_font_color): code = f""" library(fBasics) @@ -4774,7 +4863,7 @@ def Comparison_with_Bar_Chart_2(file_path, char_out_path, out_path, title, capti }} dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) layout(matrix(c(1,2,1,2),2,2),heights=c(6,1)) par(omi=c(1,0.5,1.25,0.25),mai=c(0,2.65,0.75,0.25),cex=1.5,las=1) @@ -4838,10 +4927,14 @@ def Comparison_with_Bar_Chart_2(file_path, char_out_path, out_path, title, capti # 高级参数 title_font_color, x_scale_font_color, y_scale_font_color, max_number_font_color, line_color, color, number_font_color # 示例文件 Comparison_with_Bar_Chart_3.xlsx -def Comparison_with_Bar_Chart_3(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_scale_font_size, +def Comparison_with_Bar_Chart_3(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, + x_scale_font_size, y_scale_font_size, numbers_font_size, - title_font_color, x_scale_font_color, y_scale_font_color, max_number_font_color, line_color, color, + title_font_color, x_scale_font_color, y_scale_font_color, max_number_font_color, + line_color, color, number_font_color): + color = color[4:-1] + code = f""" library(gdata) myData<-read.xls("{file_path}",skip=1,dec=".", encoding="latin1") @@ -4907,7 +5000,7 @@ def Comparison_with_Bar_Chart_3(file_path, char_out_path, out_path, title, capti }} dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(0.5,0.5,1.1,0.5),las=1) layout(matrix(data=c(1,2,3,4,5),nrow=1,ncol=5),widths=c(2.0,1,1,1,1),heights=c(1,1)) pos<-c(45,45,45,45,35) @@ -4975,11 +5068,19 @@ def Comparison_with_Bar_Chart_3(file_path, char_out_path, out_path, title, capti # 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, time_color, line_color, color # 示例文件 Daily_Values_with_Labels.a -def Daily_Values_with_Labels(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, - x_scale_font_size, y_name, y_font_size, y_scale_font_size, time_1, time_1_font_size, time_2, time_2_font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, time_color, line_color, color): +def Daily_Values_with_Labels(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, + x_font_size, + x_scale_font_size, y_name, y_font_size, y_scale_font_size, time_1, time_1_font_size, + time_2, time_2_font_size, + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + time_color, line_color, color): + color = color[4:-1] + + time_color = time_color[4:-1] + code = f""" christmas <- read.csv(file="{file_path}",head=F,sep="\t",dec=".") + attach(christmas) pdf("{out_path}.pdf") @@ -5022,7 +5123,7 @@ def Daily_Values_with_Labels(file_path, char_out_path, out_path, title, caption, mtext("{x_name}",1,line=0,adj=0.5,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(cex.axis=1.1,omi=c(1,0.5,0.95,0.5),mai=c(0.1,1.25,0.1,0.2),mgp=c(5,1,0),las=1) plot(axes=F,type="n",xlab="",ylab="{y_name}",V1,V2,col.lab="{y_font_color}",cex.lab={y_font_size}) @@ -5096,7 +5197,7 @@ def Heat_Map(file_path, char_out_path, out_path, title, caption, title_font_size mtext("{caption}",1,line=-1,adj=1,cex={title_font_size}*0.5,font=3,outer=T,col="{title_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(mai=c(0.25,0.25,0.25,1.75),omi=c(0.25,0.25,0.75,0.85),las=1) plot.new() @@ -5133,19 +5234,31 @@ def Heat_Map(file_path, char_out_path, out_path, title, caption, title_font_size # 基础参数 file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, time_1, time_2, chart_bar_y_name, chart_bar_y_font_size, chart_bar_y_scale_font_size, chart_bar_x_scale_font_size -# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, line_color, color, chart_bar_line_color, chart_bar_color, chart_bar_y_font_color, chart_bar_y_scale_font_color, chart_bar_x_scale_font_color, background_color +# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, line_color, color, chart_bar_line_color, chart_bar_color, chart_bar_y_font_color, chart_bar_y_scale_font_color, chart_bar_x_scale_font_color # 示例文件 Monthly_Values_with_Monthly_Labels_Layout.xlsx -def Monthly_Values_with_Monthly_Labels_Layout(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, - x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, time_1, time_2, - chart_bar_y_name, chart_bar_y_font_size, chart_bar_y_scale_font_size, chart_bar_x_scale_font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, line_color, - color, chart_bar_line_color, chart_bar_color, chart_bar_y_font_color, chart_bar_y_scale_font_color, +def Monthly_Values_with_Monthly_Labels_Layout(file_path, char_out_path, out_path, title, caption, subtitle, + title_font_size, + x_name, x_font_size, x_scale_font_size, y_name, y_font_size, + y_scale_font_size, time_1, time_2, + chart_bar_y_name, chart_bar_y_font_size, chart_bar_y_scale_font_size, + chart_bar_x_scale_font_size, + title_font_color, x_font_color, x_scale_font_color, y_font_color, + y_scale_font_color, line_color, + color, chart_bar_line_color, chart_bar_color, chart_bar_y_font_color, + chart_bar_y_scale_font_color, chart_bar_x_scale_font_color, background_color): + color = color[4:-1] + + background_color = background_color[4:-1] + + chart_bar_color = chart_bar_color[4:-1] + code = f""" library(gdata) library(gdata) myData<-read.xls('{file_path}',encoding="latin1") + names(myData) <- c("Monat", "Wert") attach(myData) myColour1<-rgb({color},150,maxColorValue=255) @@ -5194,7 +5307,7 @@ def Monthly_Values_with_Monthly_Labels_Layout(file_path, char_out_path, out_path mtext("{x_name}",1,line=1,adj=0.5,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) layout(matrix(c(1,2),ncol=1),heights=c(80,20)) par(cex=0.75,bg=rgb({background_color},maxColorValue=255),omi=c(0.75,0.25,0.5,0.25),mai=c(0.25,0.75,0.25,0),mgp=c(2,1,0),las=1) plot(type="n",axes=F,xlab="",ylab="{y_name}",as.Date(paste(Monat,"01",sep="-")),Wert,cex.lab={y_font_size},col.lab="{y_font_color}") @@ -5240,17 +5353,19 @@ def Monthly_Values_with_Monthly_Labels_Layout(file_path, char_out_path, out_path f"Rscript {out_path}.R") # 基础参数 file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_scale_font_size -# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, bar_color, color_1, color_2, background_color +# 高级参数 title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, bar_color, color_1, color_2 # 示例文件 Quarterly_Values_as_Columns.xlsx def Quarterly_Values_as_Columns(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, x_font_size, x_scale_font_size, y_scale_font_size, - title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, bar_color, color_1, color_2, + title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, bar_color, + color_1, color_2, background_color): code = f""" library(gplots) library(gdata) gdp<-read.xls('{file_path}',encoding="latin1") + names(gdp) <- c("year","quarter","respective","priceadjusted") x<-rev(gdp$priceadjusted) t<-unique(gdp$year) @@ -5296,7 +5411,7 @@ def Quarterly_Values_as_Columns(file_path, char_out_path, out_path, title, capti mtext("{x_name}",1,line=-1,adj=0.47,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(0.65,0.75,0.95,0.75),mai=c(0.9,0,0.25,0.02),fg="{background_color}",bg="{background_color}",las=1) par(mfcol=c(1,length(t))) @@ -5348,9 +5463,15 @@ def Quarterly_Values_as_Columns(file_path, char_out_path, out_path, title, capti # 示例文件 Quarterly_Values_as_Lines_with_Value_Labels.xlsx def Quarterly_Values_as_Lines_with_Value_Labels(file_path, char_out_path, out_path, title, caption, subtitle, - title_font_size, x_name, x_font_size, x_scale_font_size, y_scale_font_size, font_size, - title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, font_color, + title_font_size, x_name, x_font_size, x_scale_font_size, + y_scale_font_size, font_size, + title_font_color, x_font_color, x_scale_font_color, y_scale_font_color, + font_color, line_color, scale_line_color, point_color, background_color): + line_color = line_color[4:-1] + + point_color = point_color[4:-1] + code = f""" library(gdata) gdp<-read.xls('{file_path}',encoding="latin1") @@ -5402,7 +5523,7 @@ def Quarterly_Values_as_Lines_with_Value_Labels(file_path, char_out_path, out_pa mtext("{x_name}",1,line=-1,adj=0.5,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(0.65,0.75,0.95,0.75),mai=c(0.9,0,0.25,0.02),fg="{x_scale_font_color}",bg="{background_color}",las=1) plot(x,type="n",axes=F,xlim=c(2008,2012),ylim=c(560,670),xlab="",ylab="") @@ -5458,6 +5579,11 @@ def Quarterly_Values_as_Lines_with_Value_Labels(file_path, char_out_path, out_pa def Radial_Polygons_Overlay(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, legend_1, legend_2, legend_size, legend_position, title_font_color, color_1, color_2, line_color): + + color_1 = color_1[4:-1] + + color_2 = color_2[4:-1] + code = f""" library(plotrix) library(gdata) @@ -5501,7 +5627,7 @@ def Radial_Polygons_Overlay(file_path, char_out_path, out_path, title, caption, mtext(side=1,line=2,"{caption}",cex={title_font_size}*0.4,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() - scg("{out_path}.svg") + svg("{out_path}.svg") par(omi=c(1,0.25,1,1),mai=c(0,2,0,0.5),cex.axis=1.5,cex.lab=1,xpd=T,las=1) # Create chart @@ -5516,7 +5642,7 @@ def Radial_Polygons_Overlay(file_path, char_out_path, out_path, title, caption, mtext(side=1,line=2,"{caption}",cex={title_font_size}*0.4,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(1,0.25,1,1),mai=c(0,2,0,0.5),cex.axis=1.5,cex.lab=1,xpd=T,las=1) # Create chart @@ -5541,13 +5667,19 @@ def Radial_Polygons_Overlay(file_path, char_out_path, out_path, title, caption, # 示例文件 Scatter_Plot_Variant_2_Outliers_Highlighted.csv def Scatter_Plot_Variant_2_Outliers_Highlighted(file_path, char_out_path, out_path, title, caption, subtitle, - title_font_size, x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, + title_font_size, x_name, x_font_size, x_scale_font_size, y_name, + y_font_size, y_scale_font_size, annotation, annotation_size, deviations_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + title_font_color, x_font_color, x_scale_font_color, y_font_color, + y_scale_font_color, annotation_color, color_1, color_2, deviations_color, mean_line_color): + color_1 = color_1[4:-1] + + color_2 = color_2[4:-1] + code = f""" library(gdata) - myStructuralData<-read.csv(file="{file_path}",head=F) + myStructuralData<-read.csv(file="{file_path}",head=F,sep=";",dec=".") myData<-subset(myStructuralData,V2 > 0 & V34 > 10) attach(myData) myXDes<-"" @@ -5631,7 +5763,7 @@ def Scatter_Plot_Variant_2_Outliers_Highlighted(file_path, char_out_path, out_pa mtext("{x_name}",1,line=-1,adj=0.52,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(mar=c(4,4,0.5,2),omi=c(0.5,0.5,1,0),las=1) plot(type="n",xlab=myXDes,ylab=myYDes,V34,V21,xlim=c(10,26),ylim=c(-20,35),axes=F,cex.lab={y_font_size},col.lab="{y_font_color}") @@ -5718,11 +5850,15 @@ def Scatter_Plot_Variant_2_Outliers_Highlighted(file_path, char_out_path, out_pa # 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, average_line_color, celebrities_color, color_1, color_2, average_font_color # 示例文件 Scatter_Plot_Variant_3_Areas_Highlighted.xlsx -def Scatter_Plot_Variant_3_Areas_Highlighted(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, - x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, average, +def Scatter_Plot_Variant_3_Areas_Highlighted(file_path, char_out_path, out_path, title, caption, subtitle, + title_font_size, + x_name, x_font_size, x_scale_font_size, y_name, y_font_size, + y_scale_font_size, average, average_font_size, celebrities_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, - average_line_color, celebrities_color, color_1, color_2, average_font_color): + title_font_color, x_font_color, x_scale_font_color, y_font_color, + y_scale_font_color, + average_line_color, celebrities_color, color_1, color_2, + average_font_color): code = f""" library(gdata) library(gdata) @@ -5806,7 +5942,7 @@ def Scatter_Plot_Variant_3_Areas_Highlighted(file_path, char_out_path, out_path, mtext("{x_name}",1,line=-1.2,adj=0.535,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(mai=c(0.85,1,0.25,0.25),omi=c(1,0.5,1,0.5),las=1) plot(type="n",xlab="",ylab="{y_name}",h,w,xlim=c(160,220),ylim=c(50,125),axes=F,cex.lab={y_font_size},col.lab="{y_font_color}") @@ -5889,9 +6025,12 @@ def Scatter_Plot_Variant_3_Areas_Highlighted(file_path, char_out_path, out_path, # 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, line_color, color # 示例文件 Scatter_Plot_Variant_5_Connected_Points.xlsx -def Scatter_Plot_Variant_5_Connected_Points(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, - x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, font_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, +def Scatter_Plot_Variant_5_Connected_Points(file_path, char_out_path, out_path, title, caption, subtitle, + title_font_size, + x_name, x_font_size, x_scale_font_size, y_name, y_font_size, + y_scale_font_size, font_size, + title_font_color, x_font_color, x_scale_font_color, y_font_color, + y_scale_font_color, font_color, line_color, color): code = f""" library(gdata) @@ -5959,7 +6098,7 @@ def Scatter_Plot_Variant_5_Connected_Points(file_path, char_out_path, out_path, mtext("{x_name}",1,line=-1.05,adj=0.57,cex={x_font_size},font=3,outer=T,col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(mai=c(1.1,1.25,0.15,0),omi=c(1,0.5,1,0.5), mgp=c(4.5,1,0),las=1) plot(myData$grGDP, myData$grLEXP, type="n", xlab="", ylab="{y_name}", cex.lab={y_font_size}, axes=F, col.lab="{y_font_color}") @@ -6008,10 +6147,13 @@ def Scatter_Plot_Variant_5_Connected_Points(file_path, char_out_path, out_path, # 高级参数 title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, time_color # 示例文件 Scatter_Plot_With_User_Defined_Symbols.xlsx -def Scatter_Plot_With_User_Defined_Symbols(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, - x_name, x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, font_size, +def Scatter_Plot_With_User_Defined_Symbols(file_path, char_out_path, out_path, title, caption, subtitle, + title_font_size, + x_name, x_font_size, x_scale_font_size, y_name, y_font_size, + y_scale_font_size, font_size, character, time_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, font_color, + title_font_color, x_font_color, x_scale_font_color, y_font_color, + y_scale_font_color, font_color, time_color): code = f""" library(maptools) @@ -6067,7 +6209,7 @@ def Scatter_Plot_With_User_Defined_Symbols(file_path, char_out_path, out_path, t text(myX, myY, "{character}", col=myColour, cex={font_size}, xpd=T) dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(omi=c(0.5,0.5,0,0),mai=c(0.5,1.25,0,0.25),las=1) plot(myX, myY, typ="n", xlab="", ylab="", axes=F, xlim=c(0, 2000), ylim=c(0, 4000)) axis(1,col=par("bg"),col.ticks="{x_scale_font_color}",lwd.ticks=0.5,tck=-0.025,col.axis="{x_scale_font_color}",cex.axis="{x_scale_font_size}") @@ -6110,9 +6252,17 @@ def Scatter_Plot_With_User_Defined_Symbols(file_path, char_out_path, out_path, t # 示例文件 Scatter_Plot_with_Few_Points.csv def Scatter_Plot_with_Few_Points(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, - x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, annotation, number_size, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, number_font_color, color_1, + x_font_size, x_scale_font_size, y_name, y_font_size, y_scale_font_size, annotation, + number_size, + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + number_font_color, color_1, color_2, color_3, line_color): + color_1 = color_1[4:-1] + + color_2 = color_2[4:-1] + + color_3 = color_3[4:-1] + code = f""" datas <- read.csv("{file_path}", header = FALSE) @@ -6173,7 +6323,7 @@ def Scatter_Plot_with_Few_Points(file_path, char_out_path, out_path, title, capt mtext("{x_name}",1,3,adj=0.5,cex={x_font_size},col="{x_font_color}") dev.off() - png("{char_out_path}") + png("{char_out_path}",width=900,height=540) par(mai=c(2,1,1,1),omi=c(0,0,0,0),xpd=T,las=1) plot(myRevenue,myProfit,axes=F,type="n",xlab="",ylab="{y_name}",xlim=c(-20,100),ylim=c(-1,6),cex.lab={y_font_size},col.lab="{y_font_color}") @@ -6229,9 +6379,11 @@ def Scatter_Plot_with_Few_Points(file_path, char_out_path, out_path, title, capt # 高级参数 title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, name_color # 示例文件 Seasonal_Ranges_Panel.xlsx -def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, title_font_size, x_scale_font_size, y_name, y_font_size, +def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, title_font_size, x_scale_font_size, + y_name, y_font_size, y_scale_font_size, name_1, name_2, - title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, name_size, name_color): + title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, + name_font_size, name_color): code = f""" library(gplots) library(gdata) @@ -6244,10 +6396,10 @@ def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, ti myT1<-barplot2(t(cbind(NY_min,NY_max-NY_min)),col=c(NA,"{color_1}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") for (i in 1:length(myLines)) {{text(-0.8,myLines[i]+1.1,myLines[i],xpd=T,col="{y_scale_font_color}",cex={y_scale_font_size})}} text(0.25,33,"{y_name}",xpd=T,cex={y_font_size},col="{y_font_color}") - mtext(side=3,"{name_1}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_1}",cex={name_font_size},col="{name_color}") myT2<-barplot2(t(cbind(MAJ_min,MAJ_max-MAJ_min)),col=c(NA,"{color_2}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") - mtext(side=3,"{name_2}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_2}",cex={name_font_size},col="{name_color}") mtext(side=3,"{title}",cex={title_font_size},outer=T,col="{title_font_color}") mtext(side=1,"{caption}",line=-0.4,cex={title_font_size}*0.6,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() @@ -6257,10 +6409,10 @@ def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, ti myT1<-barplot2(t(cbind(NY_min,NY_max-NY_min)),col=c(NA,"{color_1}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") for (i in 1:length(myLines)) {{text(-0.8,myLines[i]+1.1,myLines[i],xpd=T,col="{y_scale_font_color}",cex={y_scale_font_size})}} text(0.25,33,"{y_name}",xpd=T,cex={y_font_size},col="{y_font_color}") - mtext(side=3,"{name_1}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_1}",cex={name_font_size},col="{name_color}") myT2<-barplot2(t(cbind(MAJ_min,MAJ_max-MAJ_min)),col=c(NA,"{color_2}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") - mtext(side=3,"{name_2}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_2}",cex={name_font_size},col="{name_color}") mtext(side=3,"{title}",cex={title_font_size},outer=T,col="{title_font_color}") mtext(side=1,"{caption}",line=-0.4,cex={title_font_size}*0.6,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() @@ -6270,10 +6422,10 @@ def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, ti myT1<-barplot2(t(cbind(NY_min,NY_max-NY_min)),col=c(NA,"{color_1}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") for (i in 1:length(myLines)) {{text(-0.8,myLines[i]+1.1,myLines[i],xpd=T,col="{y_scale_font_color}",cex={y_scale_font_size})}} text(0.25,33,"{y_name}",xpd=T,cex={y_font_size},col="{y_font_color}") - mtext(side=3,"{name_1}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_1}",cex={name_font_size},col="{name_color}") myT2<-barplot2(t(cbind(MAJ_min,MAJ_max-MAJ_min)),col=c(NA,"{color_2}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") - mtext(side=3,"{name_2}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_2}",cex={name_font_size},col="{name_color}") mtext(side=3,"{title}",cex={title_font_size},outer=T,col="{title_font_color}") mtext(side=1,"{caption}",line=-0.4,cex={title_font_size}*0.6,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() @@ -6283,10 +6435,10 @@ def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, ti myT1<-barplot2(t(cbind(NY_min,NY_max-NY_min)),col=c(NA,"{color_1}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") for (i in 1:length(myLines)) {{text(-0.8,myLines[i]+1.1,myLines[i],xpd=T,col="{y_scale_font_color}",cex={y_scale_font_size})}} text(0.25,33,"{y_name}",xpd=T,cex={y_font_size},col="{y_font_color}") - mtext(side=3,"{name_1}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_1}",cex={name_font_size},col="{name_color}") myT2<-barplot2(t(cbind(MAJ_min,MAJ_max-MAJ_min)),col=c(NA,"{color_2}"),border=NA,names.arg=Month,ylim=c(-5,35),panel.first=abline(h=myLines,col="grey",lwd=1,lty="dotted"),axes=F,cex.names="{x_scale_font_size}",col.axis="{x_scale_font_color}") - mtext(side=3,"{name_2}",cex={name_size},col="{name_color}") + mtext(side=3,"{name_2}",cex={name_font_size},col="{name_color}") mtext(side=3,"{title}",cex={title_font_size},outer=T,col="{title_font_color}") mtext(side=1,"{caption}",line=-0.4,cex={title_font_size}*0.6,adj=1,font=3,outer=T,col="{title_font_color}") dev.off() @@ -6300,9 +6452,11 @@ def Seasonal_Ranges_Panel(file_path, char_out_path, out_path, title, caption, ti # 高级参数 title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, line_color, legend_color # 示例文件 Seasonal_Ranges_Stacked.xlsx -def Seasonal_Ranges_Stacked(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_scale_font_size, +def Seasonal_Ranges_Stacked(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, + x_scale_font_size, y_name, y_font_size, y_scale_font_size, legend_1, legend_2, legend_size, - title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, line_color, + title_font_color, x_scale_font_color, y_font_color, y_scale_font_color, color_1, color_2, + line_color, legend_color): code = f""" library(gdata) @@ -6382,9 +6536,11 @@ def Seasonal_Ranges_Stacked(file_path, char_out_path, out_path, title, caption, # 高级参数 font_color, x_font_color, x_scale_font_color, y_font_color, heading_font_color, line_color, title_font_color, date_color, percent_color, main_color # 示例文件 Simplified_Gantt_Chart.xlsx -def Simplified_Gantt_Chart(file_path, char_out_path, out_path, title, caption, title_font_size, x_name, x_font_size, x_scale_font_size, +def Simplified_Gantt_Chart(file_path, char_out_path, out_path, title, caption, title_font_size, x_name, x_font_size, + x_scale_font_size, y_name, y_font_size, heading_font_size, date_size, percent_size, main_size, font_size, - font_color, x_font_color, x_scale_font_color, y_font_color, heading_font_color, line_color, title_font_color, + font_color, x_font_color, x_scale_font_color, y_font_color, heading_font_color, line_color, + title_font_color, date_color, percent_color, main_color): y_name = "\n".join(y_name) @@ -6780,7 +6936,7 @@ def Spie_chart(file_path, char_out_path, out_path, title, caption, subtitle, tit f"Rscript {out_path}.R") # 基础参数 file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, letter_1, letter_2, letter_size_1, letter_size_2 -# 高级参数 font_color, title_font_color, background_color +# 高级参数 font_color, title_font_color # 示例文件 Table_with_Symbols_of_the_Symbol_Signs_Type_Face.xlsx def Table_with_Symbols_of_the_Symbol_Signs_Type_Face(file_path, char_out_path, out_path, title, caption, subtitle, @@ -7000,10 +7156,17 @@ def Table_with_Symbols_of_the_Symbol_Signs_Type_Face(file_path, char_out_path, o # 示例文件 Time_Series_with_Trend_Panel.xlsx def Time_Series_with_Trend_Panel(file_path, char_out_path, out_path, title, caption, subtitle, title_font_size, x_name, - x_font_size, x_scale_font_size, y_font_size, y_scale_font_size, line_name_1, line_name_2, line_size_1, + x_font_size, x_scale_font_size, y_font_size, y_scale_font_size, line_name_1, + line_name_2, line_size_1, line_size_2, line_size_3, annotation, y_name_1, y_name_2, y_name_3, - title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, line_color_1, line_color_2, + title_font_color, x_font_color, x_scale_font_color, y_font_color, y_scale_font_color, + line_color_1, line_color_2, line_name_3, line_name_4): + + line_color_1 = line_color_1[4:-1] + + line_color_2 = line_color_2[4:-1] + if line_name_3 == "": line_name_3 = line_name_1 @@ -7234,7 +7397,8 @@ def Time_Series_with_Trend_Panel(file_path, char_out_path, out_path, title, capt # 高级参数 title_font_color, scale_font_color, font_color # 示例文件 chord_Diagram_1.csv chord_Diagram_2.csv -def chord_Diagram(file_path_1, file_path_2, char_out_path, out_path, title, caption, subtitle, title_font_size, font_size, +def chord_Diagram(file_path_1, file_path_2, char_out_path, out_path, title, caption, subtitle, title_font_size, + font_size, title_font_color, scale_font_color, font_color): code = f""" library("circlize") diff --git a/chart/tools.py b/chart/tools.py index 035ea2e..d94ff43 100644 --- a/chart/tools.py +++ b/chart/tools.py @@ -138,7 +138,7 @@ class ChartParameter(object): """ if parameter.input_type == "rgb": - self.colors_dict[f"{parameter.name}"] = "rgb" + parameter.input_type = self.colors_dict[f"{parameter.name}"] = "rgb" f"""