0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

crameriのcolomapをGoogleColobにインストールしたい

Posted at

batlow良さそうじゃん

突然ですが、この論文を知っていますか。
「The misuse of colour in science communication」
図作成において、どのカラーパップを用いるのが良いのかについて議論されています。
その中で紹介されているbatlowというカラーマップが視覚均等性(perceptually uniform)に優れていると、まぁざっとそんな論文です。
でもこの記事にたどり着いた人はこの論文知ってるだろうから省略。

このカラーマップのGoogleColabへのインストール方法を記載します。

インストール手順

元のサイト(Carmeriさんありがとう)

このサイトにあるzipファイルを取得後、unzipでインストールです。

簡単ですね。

zipファイルを取得
!wget https://zenodo.org/records/8409685/files/ScientificColourMaps8.zip?download=1
unzip
!unzip -q ScientificColourMaps8.zip?download=1  -d /content/ScientificColourMaps8
install
!pip install cmcrameri

試しにプロットしてみる

import cmcrameri.cm as cmc
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 1, 100)[np.newaxis, :]

plt.imshow(x, aspect='auto', cmap=cmc.batlow)
plt.axis('off')
plt.show()

ダウンロード.png

使えるカラーマップ一覧
from cmcrameri import show_cmaps

show_cmaps()

show_cmap.png

Jetは良くないかもしれないって話

import matplotlib.pyplot as plt
import numpy as np

def f(x, y):
    return np.sin(x) * np.cos(y + x)

x = np.linspace(0, 5, 1000)
y = np.linspace(0, 5, 1000)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)

fig, axs = plt.subplots(1, 2, figsize=(10, 4))

im1 = axs[0].imshow(
    Z,
    origin="lower",
    cmap="jet",
    aspect="auto"
)
axs[0].set_title("cmap = jet")
fig.colorbar(im1, ax=axs[0])

im2 = axs[1].imshow(
    Z,
    origin="lower",
    cmap=cmc.batlow,
    aspect="auto"
)
axs[1].set_title("cmap = batlow")
fig.colorbar(im2, ax=axs[1])

plt.tight_layout()
plt.savefig("map_discussion.png")
plt.show()

map_discussion.png

こう見るとjetだと輪郭があるように見えますよね?
対してbatlowは滑らかに繋がっているように見えます。
これが論文で語られていた、視覚均等性(perceptually uniform)です。

参考記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?