|
925 | 925 | "def summary_bars_plotter(summary_bars: list, results: object, ax_to_plot: object,\n", |
926 | 926 | " float_contrast: bool,summary_bars_kwargs: dict, ci_type: str,\n", |
927 | 927 | " ticks_to_plot: list, color_col: str, plot_palette_raw: dict, \n", |
928 | | - " proportional: bool, is_paired: bool):\n", |
| 928 | + " proportional: bool, is_paired: bool, horizontal: bool):\n", |
929 | 929 | " \"\"\"\n", |
930 | 930 | " Add summary bars to the contrast plot. Currently only functional for Vertical plots.\n", |
931 | 931 | "\n", |
|
953 | 953 | " Whether the data is proportional.\n", |
954 | 954 | " is_paired : bool\n", |
955 | 955 | " Whether the data is paired.\n", |
| 956 | + " horizontal : bool\n", |
| 957 | + " Whether the plot is horizontal.\n", |
956 | 958 | " \"\"\"\n", |
957 | 959 | "# Begin checks \n", |
958 | 960 | " if not isinstance(summary_bars, list):\n", |
|
966 | 968 | "# End checks\n", |
967 | 969 | " else:\n", |
968 | 970 | " summary_xmin, summary_xmax = ax_to_plot.get_xlim()\n", |
| 971 | + " summary_ymin, summary_ymax = ax_to_plot.get_ylim()\n", |
| 972 | + "\n", |
969 | 973 | " summary_bars_colors = (\n", |
970 | 974 | " [summary_bars_kwargs.get('color')]*int(max(ticks_to_plot)+1)\n", |
971 | 975 | " if summary_bars_kwargs.get('color') is not None\n", |
|
974 | 978 | " else list(plot_palette_raw.values())\n", |
975 | 979 | " )\n", |
976 | 980 | " summary_bars_kwargs.pop('color')\n", |
| 981 | + " span_ax = summary_bars_kwargs.pop(\"span_ax\")\n", |
| 982 | + "\n", |
977 | 983 | " for summary_index in summary_bars:\n", |
978 | 984 | " if ci_type == \"bca\":\n", |
979 | 985 | " summary_ci_low = results.bca_low[summary_index]\n", |
|
982 | 988 | " summary_ci_low = results.pct_low[summary_index]\n", |
983 | 989 | " summary_ci_high = results.pct_high[summary_index]\n", |
984 | 990 | "\n", |
985 | | - " summary_color = summary_bars_colors[int(ticks_to_plot[summary_index])]\n", |
986 | | - "\n", |
987 | | - " ax_to_plot.add_patch(mpatches.Rectangle((summary_xmin,summary_ci_low),summary_xmax+1, \n", |
988 | | - " summary_ci_high-summary_ci_low, zorder=-2, color=summary_color, **summary_bars_kwargs))\n", |
| 991 | + " if span_ax == True:\n", |
| 992 | + " starting_location = summary_ymax if horizontal else summary_xmin\n", |
| 993 | + " else:\n", |
| 994 | + " starting_location = ticks_to_plot[summary_index] \n", |
989 | 995 | "\n", |
| 996 | + " summary_color = summary_bars_colors[int(ticks_to_plot[summary_index])]\n", |
990 | 997 | "\n", |
| 998 | + " if horizontal:\n", |
| 999 | + " ax_to_plot.add_patch(mpatches.Rectangle(\n", |
| 1000 | + " (summary_ci_low, starting_location),\n", |
| 1001 | + " summary_ci_high-summary_ci_low, summary_ymin+1, \n", |
| 1002 | + " zorder=-2, color=summary_color, \n", |
| 1003 | + " **summary_bars_kwargs)\n", |
| 1004 | + " )\n", |
| 1005 | + " else:\n", |
| 1006 | + " ax_to_plot.add_patch(mpatches.Rectangle(\n", |
| 1007 | + " (starting_location, summary_ci_low),\n", |
| 1008 | + " summary_xmax+1, summary_ci_high-summary_ci_low, \n", |
| 1009 | + " zorder=-2, color=summary_color, \n", |
| 1010 | + " **summary_bars_kwargs)\n", |
| 1011 | + " )\n", |
| 1012 | + " \n", |
991 | 1013 | "def contrast_bars_plotter(results: object, ax_to_plot: object, swarm_plot_ax: object,\n", |
992 | 1014 | " ticks_to_plot: list, contrast_bars_kwargs: dict, color_col: str, \n", |
993 | 1015 | " plot_palette_raw: dict, show_mini_meta: bool, mini_meta_delta: object, \n", |
|
0 commit comments