From 2f5f9b3b5c0e8723bbf7c1f701c6f2d1ddf9adc5 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 3 Jun 2024 16:11:50 -0400 Subject: [PATCH] Use afmhot_u from ehtplot Looks better than colorcet's cet_fire. Someone said it looks like a black hole plot, so why not use the actual black hole plot colormap? Change std test from black to white for contrast --- examples/distributions_by_method_2D.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/distributions_by_method_2D.py b/examples/distributions_by_method_2D.py index 631b10b..ad1558d 100644 --- a/examples/distributions_by_method_2D.py +++ b/examples/distributions_by_method_2D.py @@ -27,6 +27,7 @@ import matplotlib.pyplot as plt import numpy as np +# from colorcet import fire from joblib import Parallel, delayed from elsim.elections import normal_electorate, normed_dist_utilities @@ -35,6 +36,11 @@ from elsim.strategies import (approval_optimal, honest_normed_scores, honest_rankings, vote_for_k) +try: + import ehtplot.color # Creates afmhot_u colormap +except ValueError: # "colormap … is already registered." + pass + n_elections = 1_000_000 n_voters = 1_000 n_cands = 9 @@ -188,7 +194,7 @@ def plot_distribution(ax, data, title, max_lim): range=[[-max_lim, max_lim], [-max_lim, max_lim]]) extent = [-max_lim, max_lim, -max_lim, max_lim] - ax.imshow(heatmap.T, cmap="Blues", origin='lower', + ax.imshow(heatmap.T, cmap='afmhot_u', origin='lower', aspect='auto', extent=extent) ax.set_xlim([-max_lim, max_lim]) ax.set_ylim([-max_lim, max_lim]) @@ -218,7 +224,7 @@ def plot_distribution(ax, data, title, max_lim): std = winners_stats[method][1] ax[n].text(0.98, 0.02, f'std: ({std[0]:.2f}, {std[1]:.2f})', verticalalignment='bottom', horizontalalignment='right', - transform=ax[n].transAxes, color='black', fontsize=8) + transform=ax[n].transAxes, color='white', fontsize=8) # Hide the last axes if they are not used for i in range(len(winners), len(ax)):