|
60 | 60 | "import matplotlib\n", |
61 | 61 | "import matplotlib.pyplot as plt\n", |
62 | 62 | "import matplotlib.patches as mpatches\n", |
| 63 | + "from matplotlib.lines import Line2D\n", |
63 | 64 | "import pandas as pd\n", |
64 | 65 | "import warnings\n", |
65 | 66 | "import logging" |
|
278 | 279 | "\n", |
279 | 280 | " # swarmplot() plots swarms based on current size of ax\n", |
280 | 281 | " # Therefore, since the ax size for mini_meta and show_delta changes later on, there has to be increased jitter\n", |
281 | | - " rawdata_plot = swarmplot(\n", |
282 | | - " data=plot_data,\n", |
283 | | - " x=xvar,\n", |
284 | | - " y=yvar,\n", |
285 | | - " ax=rawdata_axes,\n", |
286 | | - " order=all_plot_groups,\n", |
287 | | - " hue=xvar if color_col is None else color_col,\n", |
288 | | - " palette=plot_palette_raw,\n", |
289 | | - " zorder=1,\n", |
290 | | - " side=asymmetric_side,\n", |
291 | | - " jitter=1.25 if show_mini_meta else 1.4 if show_delta2 else 1, # TODO: to make jitter value more accurate and not just a hardcoded eyeball value\n", |
292 | | - " is_drop_gutter=True,\n", |
293 | | - " gutter_limit=0.45,\n", |
294 | | - " **swarmplot_kwargs\n", |
295 | | - " )\n", |
| 282 | + " rawdata_plot, swarm_legend_kwargs = swarmplot(\n", |
| 283 | + " data=plot_data,\n", |
| 284 | + " x=xvar,\n", |
| 285 | + " y=yvar,\n", |
| 286 | + " ax=rawdata_axes,\n", |
| 287 | + " order=all_plot_groups,\n", |
| 288 | + " hue=xvar if color_col is None else color_col,\n", |
| 289 | + " palette=plot_palette_raw,\n", |
| 290 | + " zorder=1,\n", |
| 291 | + " side=asymmetric_side,\n", |
| 292 | + " jitter=1.25 if show_mini_meta else 1.4 if show_delta2 else 1, # TODO: to make jitter value more accurate and not just a hardcoded eyeball value\n", |
| 293 | + " is_drop_gutter=True,\n", |
| 294 | + " gutter_limit=0.45,\n", |
| 295 | + " **swarmplot_kwargs\n", |
| 296 | + " )\n", |
296 | 297 | " if color_col is None:\n", |
297 | 298 | " rawdata_plot.legend().set_visible(False)\n", |
298 | 299 | "\n", |
|
443 | 444 | " handles, labels = rawdata_axes.get_legend_handles_labels()\n", |
444 | 445 | " legend_labels = [l for l in labels]\n", |
445 | 446 | " legend_handles = [h for h in handles]\n", |
446 | | - " if bootstraps_color_by_group is False:\n", |
447 | | - " rawdata_axes.legend().set_visible(False)\n", |
448 | 447 | "\n", |
449 | 448 | " if bootstraps_color_by_group is False:\n", |
| 449 | + " rawdata_axes.legend().set_visible(False)\n", |
450 | 450 | " show_legend(\n", |
451 | 451 | " legend_labels=legend_labels, \n", |
452 | 452 | " legend_handles=legend_handles, \n", |
|
457 | 457 | " legend_kwargs=legend_kwargs\n", |
458 | 458 | " )\n", |
459 | 459 | "\n", |
| 460 | + " ########## WIP LEGENDS\n", |
| 461 | + " if not show_pairs and not proportional and color_col is not None and not show_delta2:\n", |
| 462 | + " if len(np.unique(swarm_legend_kwargs['index'])) > 1:\n", |
| 463 | + " legend_elements = []\n", |
| 464 | + " for color, label in zip(swarm_legend_kwargs['colors'], swarm_legend_kwargs['labels']):\n", |
| 465 | + " legend_elements.append(Line2D([0], [0], marker='o', color='w', label=label,\n", |
| 466 | + " markerfacecolor=color, markersize=10))\n", |
| 467 | + " rawdata_axes.legend(handles=legend_elements, frameon=False)\n", |
| 468 | + "\n", |
| 469 | + " ########## WIP LEGENDS\n", |
| 470 | + "\n", |
460 | 471 | " # Plot aesthetic adjustments.\n", |
461 | 472 | " og_ylim_raw = rawdata_axes.get_ylim()\n", |
462 | 473 | " og_xlim_raw = rawdata_axes.get_xlim()\n", |
|
0 commit comments