|
256 | 256 | "\n", |
257 | 257 | "def get_kwargs(\n", |
258 | 258 | " plot_kwargs: dict, \n", |
259 | | - " ytick_color\n", |
| 259 | + " ytick_color,\n", |
| 260 | + " is_paired: bool = False\n", |
260 | 261 | " ):\n", |
261 | 262 | " \"\"\"\n", |
262 | 263 | " Extracts the kwargs from the `plot_kwargs` object for use in the plotter function.\n", |
|
267 | 268 | " Kwargs passed to the plot function.\n", |
268 | 269 | " ytick_color : str or color list\n", |
269 | 270 | " Color of the yticks.\n", |
| 271 | + " is_paired : bool, optional\n", |
| 272 | + " A boolean flag to determine if the plot is for paired data. Default is False.\n", |
270 | 273 | " \"\"\"\n", |
271 | 274 | " from .misc_tools import merge_two_dicts\n", |
272 | 275 | "\n", |
|
387 | 390 | " default_group_summaries_kwargs = {\n", |
388 | 391 | " \"zorder\": 3, \n", |
389 | 392 | " \"lw\": 2, \n", |
390 | | - " \"alpha\": 1,\n", |
| 393 | + " \"alpha\": 1 if not is_paired else 0.6,\n", |
391 | 394 | " 'gap_width_percent': 1.5,\n", |
392 | 395 | " 'offset': 0.1,\n", |
393 | 396 | " 'color': None\n", |
|
601 | 604 | " color_groups = pd.unique(plot_data[color_col])\n", |
602 | 605 | " bootstraps_color_by_group = False\n", |
603 | 606 | " if show_pairs:\n", |
604 | | - " bootstraps_color_by_group = False\n", |
| 607 | + " if plot_kwargs[\"custom_palette\"] is not None:\n", |
| 608 | + " if delta2 or sankey:\n", |
| 609 | + " bootstraps_color_by_group = False\n", |
| 610 | + " else:\n", |
| 611 | + " bootstraps_color_by_group = True\n", |
| 612 | + " else:\n", |
| 613 | + " bootstraps_color_by_group = False\n", |
605 | 614 | "\n", |
606 | 615 | " # Handle the color palette.\n", |
607 | 616 | " filled = True\n", |
|
1909 | 1918 | " elements: list, \n", |
1910 | 1919 | " color_col: str, \n", |
1911 | 1920 | " show_pairs: bool, \n", |
1912 | | - " color_palette: dict) -> list:\n", |
| 1921 | + " color_palette: dict,\n", |
| 1922 | + " bootstraps_color_by_group: bool) -> list:\n", |
1913 | 1923 | " num_of_elements = len(elements)\n", |
1914 | 1924 | " colors = (\n", |
1915 | 1925 | " [kwargs.pop('color')] * num_of_elements\n", |
1916 | 1926 | " if kwargs.get('color', None) is not None\n", |
1917 | 1927 | " else ['black'] * num_of_elements\n", |
1918 | | - " if color_col is not None or show_pairs \n", |
| 1928 | + " # if color_col is not None or show_pairs\n", |
| 1929 | + " if color_col is not None or not bootstraps_color_by_group\n", |
1919 | 1930 | " else list(color_palette.values())\n", |
1920 | 1931 | " )\n", |
1921 | 1932 | " if color_type in ['contrast', 'summary', 'delta_text']:\n", |
|
1930 | 1941 | " return final_colors\n", |
1931 | 1942 | "\n", |
1932 | 1943 | "\n", |
1933 | | - "def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, color_col, show_pairs,\n", |
| 1944 | + "def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, color_col, show_pairs, bootstraps_color_by_group,\n", |
1934 | 1945 | " plot_data = None, xvar = None, yvar = None, # Raw data\n", |
1935 | 1946 | " results = None, ticks_to_plot = None, extra_delta = None, # Contrast data\n", |
1936 | 1947 | " reference_band = None, summary_axes = None, ci_type = None # Summary data\n", |
|
2004 | 2015 | " elements = ticks_to_plot if bar_type=='contrast' else ticks, \n", |
2005 | 2016 | " color_col = color_col, \n", |
2006 | 2017 | " show_pairs = show_pairs, \n", |
2007 | | - " color_palette = plot_palette_raw\n", |
| 2018 | + " color_palette = plot_palette_raw,\n", |
| 2019 | + " bootstraps_color_by_group = bootstraps_color_by_group\n", |
2008 | 2020 | " )\n", |
2009 | 2021 | " if bar_type == 'contrast' and extra_delta is not None:\n", |
2010 | 2022 | " colors.append('black')\n", |
|
0 commit comments