-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
abm/data/metaprotocol/experiments/scripts/VisualFlocking/circular_colorwheel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from matplotlib import cm | ||
import matplotlib as mpl | ||
import colorcet as cc | ||
|
||
# choosing a colormap CET_C8 | ||
# https://colorcet.holoviz.org/user_guide/Continuous.html | ||
# https://colorcet.holoviz.org/user_guide/Discrete.html | ||
# https://colorcet.holoviz.org/user_guide/PerceptuallyUniform.html | ||
cmap = cc.cm['CET_CBC1'] | ||
|
||
fig = plt.figure() | ||
|
||
display_axes = fig.add_axes([0.1,0.1,0.8,0.8], projection='polar') | ||
display_axes._direction = 2*np.pi ## This is a nasty hack - using the hidden field to | ||
## multiply the values such that 1 become 2*pi | ||
## this field is supposed to take values 1 or -1 only!! | ||
|
||
norm = mpl.colors.Normalize(0.0, 2*np.pi) | ||
|
||
# Plot the colorbar onto the polar axis | ||
# note - use orientation horizontal so that the gradient goes around | ||
# the wheel rather than centre out | ||
quant_steps = 2056 | ||
cb = mpl.colorbar.ColorbarBase(display_axes, cmap=cmap, | ||
norm=norm, | ||
orientation='horizontal') | ||
|
||
# aesthetics - get rid of border and axis labels | ||
cb.outline.set_visible(False) | ||
display_axes.set_axis_off() | ||
display_axes.set_rlim([-1,1]) | ||
plt.show() # Replace with plt.savefig if you want to save a file |