|
663 | 663 | " else:\n", |
664 | 664 | " if not proportional:\n", |
665 | 665 | " # Plot the raw data as a swarmplot.\n", |
666 | | - " rawdata_plot = sns.swarmplot(\n", |
667 | | - " data=plot_data,\n", |
668 | | - " x=xvar,\n", |
669 | | - " y=yvar,\n", |
670 | | - " ax=rawdata_axes,\n", |
671 | | - " order=all_plot_groups,\n", |
672 | | - " hue=color_col,\n", |
673 | | - " palette=plot_palette_raw,\n", |
674 | | - " zorder=1,\n", |
675 | | - " **swarmplot_kwargs\n", |
676 | | - " )\n", |
| 666 | + " if color_col is None: # Determine the use of hue\n", |
| 667 | + " rawdata_plot = sns.swarmplot(\n", |
| 668 | + " data=plot_data,\n", |
| 669 | + " x=xvar,\n", |
| 670 | + " y=yvar,\n", |
| 671 | + " ax=rawdata_axes,\n", |
| 672 | + " order=all_plot_groups,\n", |
| 673 | + " hue=xvar,\n", |
| 674 | + " palette=plot_palette_raw,\n", |
| 675 | + " zorder=1,\n", |
| 676 | + " **swarmplot_kwargs\n", |
| 677 | + " )\n", |
| 678 | + " rawdata_plot.legend().set_visible(False)\n", |
| 679 | + " else:\n", |
| 680 | + " rawdata_plot = sns.swarmplot(\n", |
| 681 | + " data=plot_data,\n", |
| 682 | + " x=xvar,\n", |
| 683 | + " y=yvar,\n", |
| 684 | + " ax=rawdata_axes,\n", |
| 685 | + " order=all_plot_groups,\n", |
| 686 | + " hue=color_col,\n", |
| 687 | + " palette=plot_palette_raw,\n", |
| 688 | + " zorder=1,\n", |
| 689 | + " **swarmplot_kwargs\n", |
| 690 | + " )\n", |
677 | 691 | " else:\n", |
678 | 692 | " # Plot the raw data as a barplot.\n", |
679 | 693 | " bar1_df = pd.DataFrame(\n", |
|
731 | 745 | " if bootstraps_color_by_group:\n", |
732 | 746 | " line_colors.append(plot_palette_raw[all_plot_groups[jj]])\n", |
733 | 747 | "\n", |
| 748 | + " # Break the loop since hue in Seaborn adds collections to axes and it will result in index out of range\n", |
| 749 | + " if jj >= n_groups - 1 and color_col is None:\n", |
| 750 | + " break\n", |
| 751 | + "\n", |
734 | 752 | " if len(line_colors) != len(all_plot_groups):\n", |
735 | 753 | " line_colors = ytick_color\n", |
736 | 754 | "\n", |
|
1592 | 1610 | " plt.rcParams[parameter] = original_rcParams[parameter]\n", |
1593 | 1611 | "\n", |
1594 | 1612 | " # Return the figure.\n", |
1595 | | - " return fig" |
| 1613 | + " return fig\n" |
1596 | 1614 | ] |
1597 | 1615 | }, |
1598 | 1616 | { |
|
0 commit comments