Browse Source

update font

plotting-unify
Michael Pilosov, PhD 9 months ago
parent
commit
32205b2cce
  1. 12
      color_poster.py
  2. 16
      scripts/sortcolor.py

12
color_poster.py

@ -3,9 +3,14 @@ from typing import List
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
pt_mono_font = FontProperties(
fname="/usr/share/fonts/truetype/PT_Mono/PTMono-Regular.ttf"
)
# set font by default to courier new
plt.rcParams["font.family"] = "PT Mono"
# plt.rcParams["font.family"] = "PT Mono"
# # sort by the proximity to the colors in viridis
# # Importing necessary functions
@ -63,6 +68,7 @@ def create_color_calibration_image(
color.replace("xkcd:", ""),
va="center",
fontsize=fontsize,
fontproperties=pt_mono_font,
# bbox=dict(facecolor='gray', alpha=0.21),
)
ax.text(
@ -71,6 +77,7 @@ def create_color_calibration_image(
f"{hex_code}\n({rgb_triple})",
va="center",
fontsize=6,
fontproperties=pt_mono_font,
# bbox=dict(facecolor='gray', alpha=0.33),
)
# ax.text(
@ -79,6 +86,7 @@ def create_color_calibration_image(
# f"{hex_code}",
# va="center",
# fontsize=fontsize * 0.6,
# fontproperties=pt_mono_font,
# )
# Draw color square
@ -160,7 +168,7 @@ if __name__ == "__main__":
"--rows", type=int, default=73, help="Number of entries per column"
)
parser.add_argument(
"--dir", type=str, default="/Volumes/TMP/tests", help="Directory to save images"
"--dir", type=str, default="~/color/out", help="Directory to save images"
)
parser.add_argument(
"-k",

16
scripts/sortcolor.py

@ -81,10 +81,6 @@ def peano_curve(n):
return curve
PDIR = f"scripts"
Path(PDIR).mkdir(parents=True, exist_ok=True)
file_path = f"{PDIR}/{KIND}_sorted_indices.npy"
if KIND in ("lex", "alpha", "abc"):
preds = np.array(colors)
@ -114,7 +110,9 @@ elif KIND == "umap":
# Sort colors by the 1D representation
preds = embedding[:, 0]
del reducer, embedding
# Save the preds to disk
print(f"Saving {file_path}")
np.save(file_path, preds.ravel())
elif KIND in ("cielab", "lab", "ciede2000"):
from skimage.color import deltaE_ciede2000, rgb2lab
@ -148,13 +146,15 @@ elif KIND == "hsv":
else:
raise ValueError(f"Unknown kind: {KIND}")
# Save the sorted indices to disk
print(f"Saving {file_path}")
np.save(file_path, preds.ravel())
PDIR = f"scripts"
Path(PDIR).mkdir(parents=True, exist_ok=True)
file_path = f"{PDIR}/{KIND}_sorted_indices.npy"
# Sort colors by the 1D representation
sorted_indices = np.argsort(preds)
sorted_colors = [colors[i] for i in sorted_indices]
print(f"Saving {file_path}")
np.save(file_path, sorted_indices.ravel())
# # Display the sorted colors around the ring of a circle
# # Create a new figure for the circle visualization

Loading…
Cancel
Save