|
871 | 871 | "\n", |
872 | 872 | "def summary_bars_plotter(summary_bars: list, results: object, ax_to_plot: object,\n", |
873 | 873 | " float_contrast: bool,summary_bars_kwargs: dict, ci_type: str,\n", |
874 | | - " ticks_to_plot: list, color_col: str, swarm_colors: list, \n", |
| 874 | + " ticks_to_plot: list, color_col: str, plot_palette_raw: dict, \n", |
875 | 875 | " proportional: bool, is_paired: bool):\n", |
876 | 876 | " \"\"\"\n", |
877 | 877 | " Add summary bars to the contrast plot.\n", |
|
894 | 894 | " List of indices of the contrast objects.\n", |
895 | 895 | " color_col : str\n", |
896 | 896 | " Column name of the color column.\n", |
897 | | - " swarm_colors : list\n", |
898 | | - " List of colors used in the plot.\n", |
| 897 | + " plot_palette_raw : dict\n", |
| 898 | + " Dictionary of colors used in the plot.\n", |
899 | 899 | " proportional : bool\n", |
900 | 900 | " Whether the data is proportional.\n", |
901 | 901 | " is_paired : bool\n", |
|
913 | 913 | "# End checks\n", |
914 | 914 | " else:\n", |
915 | 915 | " summary_xmin, summary_xmax = ax_to_plot.get_xlim()\n", |
916 | | - " summary_bars_colors = [summary_bars_kwargs.get('color')]*(max(summary_bars)+1) if summary_bars_kwargs.get('color') is not None else ['black']*(max(summary_bars)+1) if color_col is not None or (proportional and is_paired) or is_paired else swarm_colors\n", |
| 916 | + " summary_bars_colors = (\n", |
| 917 | + " [summary_bars_kwargs.get('color')]*(max(summary_bars)+1)\n", |
| 918 | + " if summary_bars_kwargs.get('color') is not None\n", |
| 919 | + " else ['black']*(max(summary_bars)+1)\n", |
| 920 | + " if color_col is not None or (proportional and is_paired) or is_paired \n", |
| 921 | + " else list(plot_palette_raw.values())\n", |
| 922 | + " )\n", |
917 | 923 | " summary_bars_kwargs.pop('color')\n", |
918 | 924 | " for summary_index in summary_bars:\n", |
919 | 925 | " if ci_type == \"bca\":\n", |
|
1024 | 1030 | " swarm_bars_order = pd.unique(plot_data[xvar])\n", |
1025 | 1031 | "\n", |
1026 | 1032 | " swarm_means = plot_data.groupby(xvar)[yvar].mean().reindex(index=swarm_bars_order)\n", |
1027 | | - " # swarm_bars_colors = [swarm_bars_kwargs.get('color')]*(max(swarm_bars_order)+1) if swarm_bars_kwargs.get('color') is not None else ['black']*(len(swarm_bars_order)+1) if color_col is not None or is_paired else swarm_colors\n", |
1028 | 1033 | " swarm_bars_colors = (\n", |
1029 | 1034 | " [swarm_bars_kwargs.get('color')] * (max(swarm_bars_order) + 1) \n", |
1030 | 1035 | " if swarm_bars_kwargs.get('color') is not None \n", |
|
1038 | 1043 | " 0.5, swarm_bars_y, zorder=-1,color=c,**swarm_bars_kwargs))\n", |
1039 | 1044 | "\n", |
1040 | 1045 | "def delta_text_plotter(results: object, ax_to_plot: object, swarm_plot_ax: object, ticks_to_plot: list, delta_text_kwargs: dict, color_col: str, \n", |
1041 | | - " swarm_colors: list, is_paired: bool, proportional: bool, float_contrast: bool,\n", |
| 1046 | + " plot_palette_raw: dict, is_paired: bool, proportional: bool, float_contrast: bool,\n", |
1042 | 1047 | " show_mini_meta: bool, mini_meta_delta: object, show_delta2: bool, delta_delta: object):\n", |
1043 | 1048 | " \"\"\"\n", |
1044 | 1049 | " Add text to the contrast plot.\n", |
|
1057 | 1062 | " Keyword arguments for the delta text.\n", |
1058 | 1063 | " color_col : str\n", |
1059 | 1064 | " Column name of the color column.\n", |
1060 | | - " swarm_colors : list\n", |
1061 | | - " List of colors used in the plot.\n", |
| 1065 | + " plot_palette_raw : dict\n", |
| 1066 | + " Dictionary of colors used in the plot.\n", |
1062 | 1067 | " is_paired : bool\n", |
1063 | 1068 | " Whether the data is paired.\n", |
1064 | 1069 | " proportional : bool\n", |
|
1083 | 1088 | " delta_text_kwargs[\"va\"] = 'bottom' if results.difference[0] >= 0 else 'top'\n", |
1084 | 1089 | " delta_text_kwargs.pop('x_location')\n", |
1085 | 1090 | "\n", |
1086 | | - " delta_text_colors = [delta_text_kwargs.get('color')]*(max(ticks_to_plot)+1) if delta_text_kwargs.get('color') is not None else ['black']*(max(ticks_to_plot)+1) if color_col is not None or (proportional and is_paired) or is_paired else swarm_colors\n", |
| 1091 | + " delta_text_colors = (\n", |
| 1092 | + " [delta_text_kwargs.get('color')]*(max(ticks_to_plot)+1)\n", |
| 1093 | + " if delta_text_kwargs.get('color') is not None\n", |
| 1094 | + " else ['black']*(max(ticks_to_plot)+1)\n", |
| 1095 | + " if color_col is not None or (proportional and is_paired) or is_paired\n", |
| 1096 | + " else list(plot_palette_raw.values())\n", |
| 1097 | + " )\n", |
1087 | 1098 | " if show_mini_meta or show_delta2: delta_text_colors.append('black')\n", |
1088 | 1099 | " delta_text_kwargs.pop('color')\n", |
1089 | 1100 | "\n", |
|
0 commit comments