diff --git a/dabest/misc_tools.py b/dabest/misc_tools.py index 28c1ac6..0656982 100644 --- a/dabest/misc_tools.py +++ b/dabest/misc_tools.py @@ -1029,43 +1029,7 @@ def Cumming_Plot_Aesthetic_Adjustments(plot_kwargs, show_delta2, effect_size_typ end_tick = rightend_ticks_raw[k] ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs) ax.set_xlim(xlim) - del redraw_axes_kwargs["x"] - - - if not proportional: - temp_length = [(len(i) - 1) for i in idx] - else: - temp_length = [(len(i) - 1) * 2 - 1 for i in idx] - if two_col_sankey: - rightend_ticks_contrast = np.array( - [len(i) - 2 for i in idx] - ) + np.array(ticks_to_start_twocol_sankey) - elif proportional and is_paired is not None: - rightend_ticks_contrast = np.array( - [len(i) - 1 for i in idx] - ) + np.array(ticks_to_skip) - else: - rightend_ticks_contrast = np.array(temp_length) + np.array( - ticks_to_skip_contrast - ) - - for ax in [contrast_axes]: - sns.despine(ax=ax, left=True) - ylim = ax.get_ylim() - xlim = ax.get_xlim() - redraw_axes_kwargs["x"] = xlim[0] - - if two_col_sankey: - for k, start_tick in enumerate(ticks_to_start_twocol_sankey): - end_tick = rightend_ticks_contrast[k] - ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs) - else: - for k, start_tick in enumerate(ticks_to_skip_contrast): - end_tick = rightend_ticks_contrast[k] - ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs) - - ax.set_xlim(xlim) - del redraw_axes_kwargs["x"] + del redraw_axes_kwargs["x"] else: # Compute the end of each x-axes line. if two_col_sankey: @@ -1077,7 +1041,7 @@ def Cumming_Plot_Aesthetic_Adjustments(plot_kwargs, show_delta2, effect_size_typ ticks_to_skip ) - for ax in [rawdata_axes, contrast_axes]: + for ax in [rawdata_axes]: sns.despine(ax=ax, left=True) ylim = ax.get_ylim() @@ -1095,6 +1059,12 @@ def Cumming_Plot_Aesthetic_Adjustments(plot_kwargs, show_delta2, effect_size_typ ax.set_xlim(xlim) del redraw_axes_kwargs["x"] + + # Remove y ticks and labels from the contrast axes. + sns.despine(ax=contrast_axes, left=True) + contrast_axes.set_yticks([]) + contrast_axes.set_yticklabels([]) + else: contrast_axes_ylim = contrast_axes.get_ylim() if contrast_axes_ylim[0] < contrast_axes_ylim[1]: @@ -1201,9 +1171,10 @@ def Cumming_Plot_Aesthetic_Adjustments(plot_kwargs, show_delta2, effect_size_typ def General_Plot_Aesthetic_Adjustments(show_delta2, show_mini_meta, contrast_axes, redraw_axes_kwargs, plot_kwargs, yvar, effect_size_type, proportional, effectsize_df, is_paired, float_contrast, - rawdata_axes, og_ylim_raw, effect_size): + rawdata_axes, og_ylim_raw, effect_size, horizontal=False): - if show_delta2 or show_mini_meta: + + if (show_delta2 or show_mini_meta) and not horizontal: ylim = contrast_axes.get_ylim() redraw_axes_kwargs["y"] = ylim[0] x_ticks = contrast_axes.get_xticks() @@ -1257,51 +1228,97 @@ def General_Plot_Aesthetic_Adjustments(show_delta2, show_mini_meta, contrast_axe if plot_kwargs["fontsize_delta2label"] is not None: fontsize_delta2label = plot_kwargs["fontsize_delta2label"] - contrast_axes.set_ylabel(contrast_label, fontsize=fontsize_contrastylabel) - if float_contrast: - contrast_axes.yaxis.set_label_position("right") + if horizontal: + + contrast_axes.set_xlabel(contrast_label, fontsize=fontsize_contrastylabel) + # Set the rawdata axes labels appropriately + if not proportional: + rawdata_axes.set_xlabel(swarm_label, fontsize=fontsize_rawylabel) + else: + rawdata_axes.set_xlabel(bar_label, fontsize=fontsize_rawylabel) + rawdata_axes.set_ylabel("") - # Set the rawdata axes labels appropriately - if not proportional: - rawdata_axes.set_ylabel(swarm_label, fontsize=fontsize_rawylabel) - else: - rawdata_axes.set_ylabel(bar_label, fontsize=fontsize_rawylabel) - rawdata_axes.set_xlabel("") - - # Because we turned the axes frame off, we also need to draw back - # the y-spine for both axes. - if not float_contrast: - rawdata_axes.set_xlim(contrast_axes.get_xlim()) - og_xlim_raw = rawdata_axes.get_xlim() - rawdata_axes.vlines( - og_xlim_raw[0], og_ylim_raw[0], og_ylim_raw[1], **redraw_axes_kwargs - ) + # Because we turned the axes frame off, we also need to draw back + # the x-spine for both axes. + rawdata_axes.set_ylim(contrast_axes.get_ylim()) + og_xlim_raw = og_ylim_raw + new_ylim_raw = rawdata_axes.get_ylim() + + rawdata_axes.hlines( + new_ylim_raw[1], og_xlim_raw[0], og_xlim_raw[1], **redraw_axes_kwargs + ) - og_xlim_contrast = contrast_axes.get_xlim() + og_ylim_contrast = contrast_axes.get_ylim() + ypos = og_ylim_contrast[1] + + og_xlim_contrast = contrast_axes.get_xlim() + contrast_axes.hlines( + ypos, og_xlim_contrast[0], og_xlim_contrast[1], **redraw_axes_kwargs + ) + + if show_delta2: + if plot_kwargs["delta2_label"] is not None: + delta2_label = plot_kwargs["delta2_label"] + elif effect_size == "mean_diff": + delta2_label = "delta - delta" + else: + delta2_label = "deltas' g" + raise NotImplementedError("Delta2 is not yet supported for horizontal plots.") + + swarm_ylim = plot_kwargs["swarm_ylim"] + contrast_ylim = plot_kwargs["contrast_ylim"] + if swarm_ylim is None: + swarm_ylim = rawdata_axes.get_ylim() + rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0]) + if plot_kwargs['contrast_ylim'] is None: + contrast_ylim = contrast_axes.get_ylim() + contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0]) - if float_contrast: - xpos = og_xlim_contrast[1] else: - xpos = og_xlim_contrast[0] + contrast_axes.set_ylabel(contrast_label, fontsize=fontsize_contrastylabel) + if float_contrast: + contrast_axes.yaxis.set_label_position("right") + # Set the rawdata axes labels appropriately + if not proportional: + rawdata_axes.set_ylabel(swarm_label, fontsize=fontsize_rawylabel) + else: + rawdata_axes.set_ylabel(bar_label, fontsize=fontsize_rawylabel) + rawdata_axes.set_xlabel("") + + # Because we turned the axes frame off, we also need to draw back + # the y-spine for both axes. + if not float_contrast: + rawdata_axes.set_xlim(contrast_axes.get_xlim()) + og_xlim_raw = rawdata_axes.get_xlim() + rawdata_axes.vlines( + og_xlim_raw[0], og_ylim_raw[0], og_ylim_raw[1], **redraw_axes_kwargs + ) - og_ylim_contrast = contrast_axes.get_ylim() - contrast_axes.vlines( - xpos, og_ylim_contrast[0], og_ylim_contrast[1], **redraw_axes_kwargs - ) + og_xlim_contrast = contrast_axes.get_xlim() - if show_delta2: - if plot_kwargs["delta2_label"] is not None: - delta2_label = plot_kwargs["delta2_label"] - elif effect_size == "mean_diff": - delta2_label = "delta - delta" + if float_contrast: + xpos = og_xlim_contrast[1] else: - delta2_label = "deltas' g" - delta2_axes = contrast_axes.twinx() - delta2_axes.set_frame_on(False) - delta2_axes.set_ylabel(delta2_label, fontsize=fontsize_delta2label) - og_xlim_delta = contrast_axes.get_xlim() - og_ylim_delta = contrast_axes.get_ylim() - delta2_axes.set_ylim(og_ylim_delta) - delta2_axes.vlines( - og_xlim_delta[1], og_ylim_delta[0], og_ylim_delta[1], **redraw_axes_kwargs + xpos = og_xlim_contrast[0] + + og_ylim_contrast = contrast_axes.get_ylim() + contrast_axes.vlines( + xpos, og_ylim_contrast[0], og_ylim_contrast[1], **redraw_axes_kwargs ) + + if show_delta2: + if plot_kwargs["delta2_label"] is not None: + delta2_label = plot_kwargs["delta2_label"] + elif effect_size == "mean_diff": + delta2_label = "delta - delta" + else: + delta2_label = "deltas' g" + delta2_axes = contrast_axes.twinx() + delta2_axes.set_frame_on(False) + delta2_axes.set_ylabel(delta2_label, fontsize=fontsize_delta2label) + og_xlim_delta = contrast_axes.get_xlim() + og_ylim_delta = contrast_axes.get_ylim() + delta2_axes.set_ylim(og_ylim_delta) + delta2_axes.vlines( + og_xlim_delta[1], og_ylim_delta[0], og_ylim_delta[1], **redraw_axes_kwargs + ) diff --git a/dabest/plotter.py b/dabest/plotter.py index 08c32ef..7f07729 100644 --- a/dabest/plotter.py +++ b/dabest/plotter.py @@ -615,6 +615,7 @@ def effectsize_df_plotter_horizontal(effectsize_df, **plot_kwargs): set_xaxis_ticks_and_lims, show_legend, Cumming_Plot_Aesthetic_Adjustments, + General_Plot_Aesthetic_Adjustments, ) from .plot_tools import ( @@ -637,6 +638,8 @@ def effectsize_df_plotter_horizontal(effectsize_df, **plot_kwargs): # tries to get from slopegraph. logging.disable(logging.WARNING) + + # Save rcParams that I will alter, so I can reset back. original_rcParams = {} _changed_rcParams = ["axes.grid"] @@ -653,7 +656,8 @@ def effectsize_df_plotter_horizontal(effectsize_df, **plot_kwargs): effectsize_df=effectsize_df, plot_kwargs=plot_kwargs ) - + if plot_kwargs['horizontal']: + float_contrast = False (swarmplot_kwargs, barplot_kwargs, sankey_kwargs, violinplot_kwargs, slopegraph_kwargs, reflines_kwargs, legend_kwargs, group_summary_kwargs, redraw_axes_kwargs, @@ -1010,18 +1014,30 @@ def effectsize_df_plotter_horizontal(effectsize_df, **plot_kwargs): horizontal=True, ) - - - - - - - if swarm_ylim is None: - swarm_ylim = rawdata_axes.get_ylim() - rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0]) - if plot_kwargs['contrast_ylim'] is None: - contrast_ylim = contrast_axes.get_ylim() - contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0]) + # General plotting changes + General_Plot_Aesthetic_Adjustments( + show_delta2=show_delta2, + show_mini_meta=show_mini_meta, + contrast_axes=contrast_axes, + redraw_axes_kwargs=redraw_axes_kwargs, + plot_kwargs=plot_kwargs, + yvar=yvar, + effect_size_type=effect_size_type, + proportional=proportional, + effectsize_df=effectsize_df, + is_paired=is_paired, + float_contrast=float_contrast, + rawdata_axes=rawdata_axes, + og_ylim_raw=og_xlim_raw if plot_kwargs['horizontal'] else og_ylim_raw, + effect_size=effect_size, + horizontal=True, + ) + # if swarm_ylim is None: + # swarm_ylim = rawdata_axes.get_ylim() + # rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0]) + # if plot_kwargs['contrast_ylim'] is None: + # contrast_ylim = contrast_axes.get_ylim() + # contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0]) # Make sure no stray ticks appear! diff --git a/nbs/API/misc_tools.ipynb b/nbs/API/misc_tools.ipynb index d84883f..6b4b679 100644 --- a/nbs/API/misc_tools.ipynb +++ b/nbs/API/misc_tools.ipynb @@ -1084,43 +1084,7 @@ " end_tick = rightend_ticks_raw[k]\n", " ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs)\n", " ax.set_xlim(xlim)\n", - " del redraw_axes_kwargs[\"x\"] \n", - "\n", - "\n", - " if not proportional:\n", - " temp_length = [(len(i) - 1) for i in idx]\n", - " else:\n", - " temp_length = [(len(i) - 1) * 2 - 1 for i in idx]\n", - " if two_col_sankey:\n", - " rightend_ticks_contrast = np.array(\n", - " [len(i) - 2 for i in idx]\n", - " ) + np.array(ticks_to_start_twocol_sankey)\n", - " elif proportional and is_paired is not None:\n", - " rightend_ticks_contrast = np.array(\n", - " [len(i) - 1 for i in idx]\n", - " ) + np.array(ticks_to_skip)\n", - " else:\n", - " rightend_ticks_contrast = np.array(temp_length) + np.array(\n", - " ticks_to_skip_contrast\n", - " ) \n", - "\n", - " for ax in [contrast_axes]:\n", - " sns.despine(ax=ax, left=True)\n", - " ylim = ax.get_ylim()\n", - " xlim = ax.get_xlim()\n", - " redraw_axes_kwargs[\"x\"] = xlim[0]\n", - "\n", - " if two_col_sankey:\n", - " for k, start_tick in enumerate(ticks_to_start_twocol_sankey):\n", - " end_tick = rightend_ticks_contrast[k]\n", - " ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs)\n", - " else:\n", - " for k, start_tick in enumerate(ticks_to_skip_contrast):\n", - " end_tick = rightend_ticks_contrast[k]\n", - " ax.vlines(ymin=start_tick, ymax=end_tick, **redraw_axes_kwargs)\n", - "\n", - " ax.set_xlim(xlim)\n", - " del redraw_axes_kwargs[\"x\"] \n", + " del redraw_axes_kwargs[\"x\"] \n", " else:\n", " # Compute the end of each x-axes line.\n", " if two_col_sankey:\n", @@ -1132,7 +1096,7 @@ " ticks_to_skip\n", " )\n", "\n", - " for ax in [rawdata_axes, contrast_axes]:\n", + " for ax in [rawdata_axes]:\n", " sns.despine(ax=ax, left=True)\n", "\n", " ylim = ax.get_ylim()\n", @@ -1150,6 +1114,12 @@ "\n", " ax.set_xlim(xlim)\n", " del redraw_axes_kwargs[\"x\"]\n", + "\n", + " # Remove y ticks and labels from the contrast axes.\n", + " sns.despine(ax=contrast_axes, left=True)\n", + " contrast_axes.set_yticks([])\n", + " contrast_axes.set_yticklabels([])\n", + "\n", " else:\n", " contrast_axes_ylim = contrast_axes.get_ylim()\n", " if contrast_axes_ylim[0] < contrast_axes_ylim[1]:\n", @@ -1256,9 +1226,10 @@ "\n", "def General_Plot_Aesthetic_Adjustments(show_delta2, show_mini_meta, contrast_axes, redraw_axes_kwargs, plot_kwargs,\n", " yvar, effect_size_type, proportional, effectsize_df, is_paired, float_contrast,\n", - " rawdata_axes, og_ylim_raw, effect_size):\n", + " rawdata_axes, og_ylim_raw, effect_size, horizontal=False):\n", "\n", - " if show_delta2 or show_mini_meta:\n", + "\n", + " if (show_delta2 or show_mini_meta) and not horizontal:\n", " ylim = contrast_axes.get_ylim()\n", " redraw_axes_kwargs[\"y\"] = ylim[0]\n", " x_ticks = contrast_axes.get_xticks()\n", @@ -1312,54 +1283,100 @@ " if plot_kwargs[\"fontsize_delta2label\"] is not None:\n", " fontsize_delta2label = plot_kwargs[\"fontsize_delta2label\"]\n", "\n", - " contrast_axes.set_ylabel(contrast_label, fontsize=fontsize_contrastylabel)\n", - " if float_contrast:\n", - " contrast_axes.yaxis.set_label_position(\"right\")\n", + " if horizontal:\n", + " \n", + " contrast_axes.set_xlabel(contrast_label, fontsize=fontsize_contrastylabel)\n", + " # Set the rawdata axes labels appropriately\n", + " if not proportional:\n", + " rawdata_axes.set_xlabel(swarm_label, fontsize=fontsize_rawylabel)\n", + " else:\n", + " rawdata_axes.set_xlabel(bar_label, fontsize=fontsize_rawylabel)\n", + " rawdata_axes.set_ylabel(\"\")\n", "\n", - " # Set the rawdata axes labels appropriately\n", - " if not proportional:\n", - " rawdata_axes.set_ylabel(swarm_label, fontsize=fontsize_rawylabel)\n", - " else:\n", - " rawdata_axes.set_ylabel(bar_label, fontsize=fontsize_rawylabel)\n", - " rawdata_axes.set_xlabel(\"\")\n", - "\n", - " # Because we turned the axes frame off, we also need to draw back\n", - " # the y-spine for both axes.\n", - " if not float_contrast:\n", - " rawdata_axes.set_xlim(contrast_axes.get_xlim())\n", - " og_xlim_raw = rawdata_axes.get_xlim()\n", - " rawdata_axes.vlines(\n", - " og_xlim_raw[0], og_ylim_raw[0], og_ylim_raw[1], **redraw_axes_kwargs\n", - " )\n", + " # Because we turned the axes frame off, we also need to draw back\n", + " # the x-spine for both axes.\n", + " rawdata_axes.set_ylim(contrast_axes.get_ylim())\n", + " og_xlim_raw = og_ylim_raw\n", + " new_ylim_raw = rawdata_axes.get_ylim()\n", + "\n", + " rawdata_axes.hlines(\n", + " new_ylim_raw[1], og_xlim_raw[0], og_xlim_raw[1], **redraw_axes_kwargs\n", + " )\n", "\n", - " og_xlim_contrast = contrast_axes.get_xlim()\n", + " og_ylim_contrast = contrast_axes.get_ylim()\n", + " ypos = og_ylim_contrast[1]\n", + "\n", + " og_xlim_contrast = contrast_axes.get_xlim()\n", + " contrast_axes.hlines(\n", + " ypos, og_xlim_contrast[0], og_xlim_contrast[1], **redraw_axes_kwargs\n", + " )\n", + "\n", + " if show_delta2:\n", + " if plot_kwargs[\"delta2_label\"] is not None:\n", + " delta2_label = plot_kwargs[\"delta2_label\"]\n", + " elif effect_size == \"mean_diff\":\n", + " delta2_label = \"delta - delta\"\n", + " else:\n", + " delta2_label = \"deltas' g\"\n", + " raise NotImplementedError(\"Delta2 is not yet supported for horizontal plots.\")\n", + " \n", + " swarm_ylim = plot_kwargs[\"swarm_ylim\"]\n", + " contrast_ylim = plot_kwargs[\"contrast_ylim\"]\n", + " if swarm_ylim is None:\n", + " swarm_ylim = rawdata_axes.get_ylim()\n", + " rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0])\n", + " if plot_kwargs['contrast_ylim'] is None:\n", + " contrast_ylim = contrast_axes.get_ylim()\n", + " contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0])\n", "\n", - " if float_contrast:\n", - " xpos = og_xlim_contrast[1]\n", " else:\n", - " xpos = og_xlim_contrast[0]\n", + " contrast_axes.set_ylabel(contrast_label, fontsize=fontsize_contrastylabel)\n", + " if float_contrast:\n", + " contrast_axes.yaxis.set_label_position(\"right\")\n", + " # Set the rawdata axes labels appropriately\n", + " if not proportional:\n", + " rawdata_axes.set_ylabel(swarm_label, fontsize=fontsize_rawylabel)\n", + " else:\n", + " rawdata_axes.set_ylabel(bar_label, fontsize=fontsize_rawylabel)\n", + " rawdata_axes.set_xlabel(\"\")\n", + "\n", + " # Because we turned the axes frame off, we also need to draw back\n", + " # the y-spine for both axes.\n", + " if not float_contrast:\n", + " rawdata_axes.set_xlim(contrast_axes.get_xlim())\n", + " og_xlim_raw = rawdata_axes.get_xlim()\n", + " rawdata_axes.vlines(\n", + " og_xlim_raw[0], og_ylim_raw[0], og_ylim_raw[1], **redraw_axes_kwargs\n", + " )\n", "\n", - " og_ylim_contrast = contrast_axes.get_ylim()\n", - " contrast_axes.vlines(\n", - " xpos, og_ylim_contrast[0], og_ylim_contrast[1], **redraw_axes_kwargs\n", - " )\n", + " og_xlim_contrast = contrast_axes.get_xlim()\n", "\n", - " if show_delta2:\n", - " if plot_kwargs[\"delta2_label\"] is not None:\n", - " delta2_label = plot_kwargs[\"delta2_label\"]\n", - " elif effect_size == \"mean_diff\":\n", - " delta2_label = \"delta - delta\"\n", + " if float_contrast:\n", + " xpos = og_xlim_contrast[1]\n", " else:\n", - " delta2_label = \"deltas' g\"\n", - " delta2_axes = contrast_axes.twinx()\n", - " delta2_axes.set_frame_on(False)\n", - " delta2_axes.set_ylabel(delta2_label, fontsize=fontsize_delta2label)\n", - " og_xlim_delta = contrast_axes.get_xlim()\n", - " og_ylim_delta = contrast_axes.get_ylim()\n", - " delta2_axes.set_ylim(og_ylim_delta)\n", - " delta2_axes.vlines(\n", - " og_xlim_delta[1], og_ylim_delta[0], og_ylim_delta[1], **redraw_axes_kwargs\n", - " )" + " xpos = og_xlim_contrast[0]\n", + "\n", + " og_ylim_contrast = contrast_axes.get_ylim()\n", + " contrast_axes.vlines(\n", + " xpos, og_ylim_contrast[0], og_ylim_contrast[1], **redraw_axes_kwargs\n", + " )\n", + "\n", + " if show_delta2:\n", + " if plot_kwargs[\"delta2_label\"] is not None:\n", + " delta2_label = plot_kwargs[\"delta2_label\"]\n", + " elif effect_size == \"mean_diff\":\n", + " delta2_label = \"delta - delta\"\n", + " else:\n", + " delta2_label = \"deltas' g\"\n", + " delta2_axes = contrast_axes.twinx()\n", + " delta2_axes.set_frame_on(False)\n", + " delta2_axes.set_ylabel(delta2_label, fontsize=fontsize_delta2label)\n", + " og_xlim_delta = contrast_axes.get_xlim()\n", + " og_ylim_delta = contrast_axes.get_ylim()\n", + " delta2_axes.set_ylim(og_ylim_delta)\n", + " delta2_axes.vlines(\n", + " og_xlim_delta[1], og_ylim_delta[0], og_ylim_delta[1], **redraw_axes_kwargs\n", + " )" ] } ], diff --git a/nbs/API/plotter.ipynb b/nbs/API/plotter.ipynb index ed6bb59..559990e 100644 --- a/nbs/API/plotter.ipynb +++ b/nbs/API/plotter.ipynb @@ -722,6 +722,7 @@ " set_xaxis_ticks_and_lims,\n", " show_legend,\n", " Cumming_Plot_Aesthetic_Adjustments,\n", + " General_Plot_Aesthetic_Adjustments,\n", "\n", " )\n", " from .plot_tools import (\n", @@ -744,6 +745,8 @@ " # tries to get from slopegraph.\n", " logging.disable(logging.WARNING)\n", "\n", + "\n", + "\n", " # Save rcParams that I will alter, so I can reset back.\n", " original_rcParams = {}\n", " _changed_rcParams = [\"axes.grid\"]\n", @@ -760,7 +763,8 @@ " effectsize_df=effectsize_df, \n", " plot_kwargs=plot_kwargs\n", " )\n", - " \n", + " if plot_kwargs['horizontal']:\n", + " float_contrast = False\n", " \n", " (swarmplot_kwargs, barplot_kwargs, sankey_kwargs, violinplot_kwargs, \n", " slopegraph_kwargs, reflines_kwargs, legend_kwargs, group_summary_kwargs, redraw_axes_kwargs, \n", @@ -1117,18 +1121,30 @@ " horizontal=True,\n", " )\n", "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - " if swarm_ylim is None:\n", - " swarm_ylim = rawdata_axes.get_ylim()\n", - " rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0])\n", - " if plot_kwargs['contrast_ylim'] is None:\n", - " contrast_ylim = contrast_axes.get_ylim()\n", - " contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0])\n", + " # General plotting changes\n", + " General_Plot_Aesthetic_Adjustments(\n", + " show_delta2=show_delta2, \n", + " show_mini_meta=show_mini_meta, \n", + " contrast_axes=contrast_axes, \n", + " redraw_axes_kwargs=redraw_axes_kwargs, \n", + " plot_kwargs=plot_kwargs,\n", + " yvar=yvar, \n", + " effect_size_type=effect_size_type, \n", + " proportional=proportional, \n", + " effectsize_df=effectsize_df, \n", + " is_paired=is_paired, \n", + " float_contrast=float_contrast,\n", + " rawdata_axes=rawdata_axes, \n", + " og_ylim_raw=og_xlim_raw if plot_kwargs['horizontal'] else og_ylim_raw, \n", + " effect_size=effect_size,\n", + " horizontal=True,\n", + " )\n", + " # if swarm_ylim is None:\n", + " # swarm_ylim = rawdata_axes.get_ylim()\n", + " # rawdata_axes.set_ylim(swarm_ylim[1], swarm_ylim[0])\n", + " # if plot_kwargs['contrast_ylim'] is None:\n", + " # contrast_ylim = contrast_axes.get_ylim()\n", + " # contrast_axes.set_ylim(contrast_ylim[1], contrast_ylim[0])\n", "\n", "\n", " # Make sure no stray ticks appear!\n",