diff --git a/src/jamstats/plots/advanced_plots.py b/src/jamstats/plots/advanced_plots.py index bb16e87..9c58c92 100644 --- a/src/jamstats/plots/advanced_plots.py +++ b/src/jamstats/plots/advanced_plots.py @@ -54,16 +54,18 @@ def plot(self, derby_game: DerbyGame) -> Figure: "team": [derby_game.team_1_name, derby_game.team_2_name], "jammers": [sum(pdf_jammer_jamcounts.team == derby_game.team_1_name), sum(pdf_jammer_jamcounts.team == derby_game.team_2_name)] - }), hue="team", legend=False, + }), hue="team", ax=ax, palette=team_color_palette) + ax.get_legend().remove() # word-wrap too-long team names wordwrap_x_labels(ax) ax.set_title("Jammers per team") ax = axes[1] sns.violinplot(x="team", y="jam_count", data=pdf_jammer_jamcounts, cut=0, ax=ax, - hue="team", legend=False, + hue="team", palette=team_color_palette, inner="stick") + ax.get_legend().remove() ax.set_title("Jams per jammer") ax.set_ylabel("Jams per jammer") # word-wrap too-long team names @@ -289,10 +291,11 @@ def plot(self, derby_game: DerbyGame) -> Figure: }) if len(pdf_plot) > 0: sns.violinplot(y="first_scoring_pass_durations", x="Team", - data=pdf_plot, cut=0, ax=ax, hue="Team", legend=False, + data=pdf_plot, cut=0, ax=ax, hue="Team", inner="stick", palette=team_color_palette) ax.set_ylabel("Time to Initial (s)") ax.set_title("Time to Initial per jam") + ax.get_legend().remove() # word-wrap too-long team names wordwrap_x_labels(ax) diff --git a/src/jamstats/plots/basic_plots.py b/src/jamstats/plots/basic_plots.py index 59038bb..0c99992 100644 --- a/src/jamstats/plots/basic_plots.py +++ b/src/jamstats/plots/basic_plots.py @@ -60,35 +60,40 @@ def plot(self, derby_game: DerbyGame) -> Figure: mypalette = sns.color_palette("rainbow", n_colors=n_jammers) ax = ax0 - sns.barplot(y="Jammer", x="Jams", hue="Jammer", legend=False, + sns.barplot(y="Jammer", x="Jams", hue="Jammer", data=pdf_jammer_data, ax=ax, palette=mypalette) ax.set_ylabel("") + ax.get_legend().remove() ax = ax1 - sns.barplot(y="Jammer", x="Total Score", hue="Jammer", legend=False, + sns.barplot(y="Jammer", x="Total Score", hue="Jammer", data=pdf_jammer_data, ax=ax, palette=mypalette) ax.set_yticks([]) ax.set_ylabel("") + ax.get_legend().remove() ax = ax2 - sns.barplot(y="Jammer", x="Mean Net Points", hue="Jammer", legend=False, + sns.barplot(y="Jammer", x="Mean Net Points", hue="Jammer", data=pdf_jammer_data, ax=ax, palette=mypalette) ax.set_xlabel("Mean Net Points/Jam\n(own - opposing)") ax.set_yticks([]) ax.set_ylabel("") + ax.get_legend().remove() ax = ax3 - sns.barplot(y="Jammer", x="Proportion Lead", hue="Jammer", legend=False, + sns.barplot(y="Jammer", x="Proportion Lead", hue="Jammer", data=pdf_jammer_data, ax=ax, palette=mypalette) ax.set_xlim(0,1) ax.set_yticks([]) ax.set_ylabel("") + ax.get_legend().remove() ax = ax4 - sns.barplot(y="Jammer", x="Mean Time to Initial", hue="Jammer", legend=False, + sns.barplot(y="Jammer", x="Mean Time to Initial", hue="Jammer", data=pdf_jammer_data, ax=ax, palette=mypalette) ax.set_yticks([]) ax.set_ylabel("") + ax.get_legend().remove() f.set_size_inches(16, min(2 + len(pdf_jammer_data), 11)) f.suptitle(f"Jammer Stats: {team_name}") @@ -202,12 +207,14 @@ def plot(self, derby_game: DerbyGame) -> Figure: sns.barplot(y="prd_jam", x="Team with Lead", data=pdf_for_plot_all, ax=ax, color="gray") if len(pdf_for_plot_called_or_lost) > 0: - sns.barplot(y="prd_jam", x="Team with Lead", hue="Team with Lead", legend=False, + sns.barplot(y="prd_jam", x="Team with Lead", hue="Team with Lead", data=pdf_for_plot_called_or_lost, ax=ax, palette=team_color_palette) if len(pdf_for_plot_lost) > 0: - sns.barplot(y="prd_jam", x="Team with Lead", hue="Team with Lead", legend=False, + sns.barplot(y="prd_jam", x="Team with Lead", hue="Team with Lead", data=pdf_for_plot_lost, ax=ax, palette='dark:black') + if ax.get_legend() is not None: + ax.get_legend().remove() ax.set_ylabel("Jams") ax.set_title("Jams with Lead\n(black=lost, gray=not called)")