Skip to content

Commit

Permalink
Use afmhot_u from ehtplot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
endolith committed Aug 6, 2024
1 parent 849bf42 commit 2f5f9b3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/distributions_by_method_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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)):
Expand Down

0 comments on commit 2f5f9b3

Please sign in to comment.