@@ -335,6 +335,7 @@ def get_analysis(
335335 re_order_comparates (df_results = df_results , analysis = analysis )
336336
337337 if save_as_json :
338+ print (save_file )
338339 with open (save_file , "w" ) as fjson :
339340 json .dump (analysis , fjson , cls = NpEncoder )
340341
@@ -759,71 +760,67 @@ def draw(
759760 plt .savefig (
760761 os .path .join (output_dir + f"{ pdf_savename } .pdf" ), bbox_inches = "tight"
761762 )
762- plt .cla ()
763- plt .clf ()
764- plt .close ()
765- elif png_savename is not None :
763+
764+ if png_savename is not None :
766765 plt .savefig (
767766 os .path .join (output_dir + f"{ png_savename } .png" ), bbox_inches = "tight"
768767 )
769- plt .cla ()
770- plt .clf ()
771-
772- latex_string += (
773- f"\\ begin{{tabular}}{{{ 'c' * (len (latex_table [0 ]) + 1 )} }}\n " # +1 for labels
774- )
775- for latex_row in latex_table :
776- latex_string += " & " .join (latex_row ) + " \\ \\ [1ex]" + "\n "
777768
778- if colorbar_orientation == "horizontal" :
779- latex_string += "\\ end{tabular}\\ \\ \n "
780- else :
781- latex_string += "\\ end{tabular}\n "
769+ if tex_savename is not None :
770+ latex_string += (
771+ f"\\ begin{{tabular}}{{{ 'c' * (len (latex_table [0 ]) + 1 )} }}\n " # +1 for labels
772+ )
773+ for latex_row in latex_table :
774+ latex_string += " & " .join (latex_row ) + " \\ \\ [1ex]" + "\n "
782775
783- latex_colorbar_0 = "\\ begin{tikzpicture}[baseline=(current bounding box.center)]\\ begin{axis}[hide axis,scale only axis,"
784- latex_colorbar_1 = f"colormap={{cm}}{{rgb255(1)=({ ',' .join ([str (int (_ * 255 )) for _ in cm (cm_norm (min_value ))[:- 1 ]])} ) rgb255(2)=(220,220,220) rgb255(3)=({ ',' .join ([str (int (_ * 255 )) for _ in cm (cm_norm (max_value ))[:- 1 ]])} )}},"
785- latex_colorbar_2 = (
786- f"colorbar horizontal,point meta min={ _vmin :.02f} ,point meta max={ _vmax :.02f} ,"
787- )
788- latex_colorbar_3 = "colorbar/width=1.0em"
789- latex_colorbar_4 = "}] \\ addplot[draw=none] {0};\\ end{axis}\\ end{tikzpicture}"
776+ if colorbar_orientation == "horizontal" :
777+ latex_string += "\\ end{tabular}\\ \\ \n "
778+ else :
779+ latex_string += "\\ end{tabular}\n "
790780
791- if colorbar_orientation == "horizontal" :
792- latex_string += (
793- latex_colorbar_0
794- + "width=0sp,height=0sp,colorbar horizontal,colorbar style={width=0.25\linewidth,"
795- + latex_colorbar_1
796- + latex_colorbar_2
797- + latex_colorbar_3
798- + ",scaled x ticks=false,xticklabel style={/pgf/number format/fixed,/pgf/number format/precision=3},"
799- + f"xlabel={{{ _colorbar_value } }},"
800- + latex_colorbar_4
781+ latex_colorbar_0 = "\\ begin{tikzpicture}[baseline=(current bounding box.center)]\\ begin{axis}[hide axis,scale only axis,"
782+ latex_colorbar_1 = f"colormap={{cm}}{{rgb255(1)=({ ',' .join ([str (int (_ * 255 )) for _ in cm (cm_norm (min_value ))[:- 1 ]])} ) rgb255(2)=(220,220,220) rgb255(3)=({ ',' .join ([str (int (_ * 255 )) for _ in cm (cm_norm (max_value ))[:- 1 ]])} )}},"
783+ latex_colorbar_2 = (
784+ f"colorbar horizontal,point meta min={ _vmin :.02f} ,point meta max={ _vmax :.02f} ,"
801785 )
802- else :
786+ latex_colorbar_3 = "colorbar/width=1.0em"
787+ latex_colorbar_4 = "}] \\ addplot[draw=none] {0};\\ end{axis}\\ end{tikzpicture}"
788+
789+ if colorbar_orientation == "horizontal" :
790+ latex_string += (
791+ latex_colorbar_0
792+ + "width=0sp,height=0sp,colorbar horizontal,colorbar style={width=0.25\linewidth,"
793+ + latex_colorbar_1
794+ + latex_colorbar_2
795+ + latex_colorbar_3
796+ + ",scaled x ticks=false,xticklabel style={/pgf/number format/fixed,/pgf/number format/precision=3},"
797+ + f"xlabel={{{ _colorbar_value } }},"
798+ + latex_colorbar_4
799+ )
800+ else :
801+ latex_string += (
802+ latex_colorbar_0
803+ + "width=1pt,colorbar right,colorbar style={height=0.25\linewidth,"
804+ + latex_colorbar_1
805+ + latex_colorbar_2
806+ + latex_colorbar_3
807+ + ",scaled y ticks=false,ylabel style={rotate=180},yticklabel style={/pgf/number format/fixed,/pgf/number format/precision=3},"
808+ + f"ylabel={{{ _colorbar_value } }},"
809+ + latex_colorbar_4
810+ )
811+
812+ latex_string += "\\ end{center}\n "
803813 latex_string += (
804- latex_colorbar_0
805- + "width=1pt,colorbar right,colorbar style={height=0.25\linewidth,"
806- + latex_colorbar_1
807- + latex_colorbar_2
808- + latex_colorbar_3
809- + ",scaled y ticks=false,ylabel style={rotate=180},yticklabel style={/pgf/number format/fixed,/pgf/number format/precision=3},"
810- + f"ylabel={{{ _colorbar_value } }},"
811- + latex_colorbar_4
814+ "\\ caption{[...] \\ textbf{"
815+ + f"{ p_value_text } " .replace ("\n " , " " )
816+ + "} [...]}\n "
812817 )
818+ latex_string += "\\ end{table}\n "
819+ latex_string += "\\ end{document}\n "
813820
814- latex_string += "\\ end{center}\n "
815- latex_string += (
816- "\\ caption{[...] \\ textbf{"
817- + f"{ p_value_text } " .replace ("\n " , " " )
818- + "} [...]}\n "
819- )
820- latex_string += "\\ end{table}\n "
821- latex_string += "\\ end{document}\n "
822-
823- latex_string = latex_string .replace (">" , "$>$" )
824- latex_string = latex_string .replace ("<" , "$<$" )
825-
826- if tex_savename is not None :
821+ latex_string = latex_string .replace (">" , "$>$" )
822+ latex_string = latex_string .replace ("<" , "$<$" )
823+
827824 with open (
828825 f"{ output_dir } /{ tex_savename } .tex" , "w" , encoding = "utf8" , newline = "\n "
829826 ) as file :
@@ -837,3 +834,7 @@ def draw(
837834
838835 if tex_savename is None and pdf_savename is None and png_savename is None :
839836 plt .show ()
837+
838+ plt .cla ()
839+ plt .clf ()
840+ plt .close ()
0 commit comments