matplotlibのstyleはどれが良いか

# 初めに
[以前の投稿](https://qiita.com/ShotaDeguchi/items/c24a89272e651c3de58c)に引き続き，グラフに少しだけ凝ってみる．

[matplotlib](https://matplotlib.org/stable/)でグラフを描画するときは，

```python
import matplotlib.pyplot as plt
plt.style.use(STYLE)   # STYLE: str
```

を宣言することで，描画スタイルを選択できる．

[公式のdocumentation](https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html)に幾つかの例が示されているが，興味のあるスタイルのみ取り出して比較する．

# 比較
[以前の投稿](https://qiita.com/ShotaDeguchi/items/c24a89272e651c3de58c)より，グラフのアスペクト比は大和比（7 : 5）で描画する．

2Dと3Dの図を作り，様子を確認する．

| style | 2D | 3D |
|:-:|:-:|:-:|
| default | ![default_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/0fef4776-48e3-cff2-a5a7-c9f9fe100737.png) | ![default_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/87b64bd1-d5fa-bfd8-1eb8-16e9946424f7.png) |
| fast | ![fast_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/de14aee8-e17a-e026-6fec-aa117403172e.png) | ![fast_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/508d7974-b560-73d1-30c8-305c558f4e12.png) |
| seaborn-white | ![seaborn-white_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/d9d1735f-099c-633d-845d-07d6d67e267e.png) | ![seaborn-white_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/74b6f08c-014b-45b2-3d50-225b2f89d6c8.png) |
| _mpl-gallery | ![_mpl-gallery_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/f9f45f5d-e73a-bc40-b3e5-14e628e5ebe2.png) | ![_mpl-gallery_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/a6631f72-90f8-4c67-ec23-f406d1383fdb.png) |
| bmh | ![bmh_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/4cd250ea-9b29-0b23-5ccd-f4156028d903.png) | ![bmh_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/d2a30c13-93b9-425a-6007-b77982ac6ab8.png) |
| classic | ![classic_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/6349718f-0b75-b025-2b6a-c0f8236fdc30.png) | ![classic_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/8be85de3-d0fe-3679-2650-ae0c75cf57b1.png) |
| dark_background | ![dark_background_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/abd6f306-8a80-bc55-dbe2-8f2298e56f92.png) | ![dark_background_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/9333b65d-01bc-bd97-c59d-f7f1960cb675.png) |
| ggplot | ![ggplot_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/eee84b67-c1c8-9bec-28fa-2d4b2826db28.png) | ![ggplot_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/044f23e8-acc7-245e-9d5f-b3f1075aa853.png) |
| tableau-colorblind10 | ![tableau-colorblind10_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/35200797-181a-36fb-f0f8-87d51f49211d.png) | ![tableau-colorblind10_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/a8386512-30b8-d129-b252-afc56bb5b2cd.png) |
| seaborn-colorblind | ![seaborn-colorblind_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/f34b41a1-c41e-2ebb-6f22-a28ff4f788b3.png) | ![seaborn-colorblind_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/be3e2ae4-d349-59fc-e69f-79e5bd95ec8e.png) |
| seaborn | ![seaborn_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/a28956cd-ec49-0982-3c83-f6e9fb60f355.png) | ![seaborn_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/c2cfb4d9-94b8-1853-c631-c0afb8c2a1b2.png) |
| seaborn-deep | ![seaborn-deep_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/6e6c1612-da46-401f-2529-9404e13bc2bc.png) | ![seaborn-deep_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/767bec82-374d-1a9c-fed6-2087bf2659bb.png) |
| seaborn-muted | ![seaborn-muted_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/ca7d90c7-2221-7b45-14dc-7f6b18c5e4d6.png) | ![seaborn-muted_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/2f0a9751-718c-63ad-aa06-80026b0e775c.png) |
| seaborn-poster | ![seaborn-poster_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/64f2c79b-bfd4-34c9-ec28-af57d90fd7b4.png) | ![seaborn-poster_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/21f1bff7-10fc-9cc8-7d11-76186cfdd791.png) |
| seaborn-talk | ![seaborn-talk_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/acbccfc5-31eb-bbaf-1d1a-a186fad4df09.png) | ![seaborn-talk_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/10b0eb3a-cf43-3182-6aec-55650f349139.png) |
| seaborn-notebook | ![seaborn-notebook_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/cbbe895f-c9b8-7e32-15e2-3a09565138f0.png) | ![seaborn-notebook_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/6aefa97c-2e5a-6fe1-4ea5-64982c567dfd.png) |
| seaborn-paper | ![seaborn-paper_2d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/ae234ca7-0dd8-8a3d-6b8d-ad8e4f8be075.png) | ![seaborn-paper_3d.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2529612/38aa8cd1-73b9-fe13-8b47-3aff072a1512.png) |


`default`と`fast`は殆ど違いが無いように見える．`seaborn-white`も似ているが，枠線の太さ，tickの有無，legendのボックスの塗り潰しの有無などが違う．

個人的に`bmh`は好きだったが，3Dで背景に影が入るのが面倒（なぜかは良く分かっていない）．他にも，3Dで背景に色が付くもの（`ggplot`など）は避けたい．

色覚異常を持つ方にもフレンドリーなスタイルに，`tableau-colorblind10`と`seaborn-colorblind`がある．幸い色覚異常の無い私には，`seaborn-colorblind`のカラーサイクルの方が好みだ．

`seaborn`も背景に色が付くので避けたいが，背景が白色でカラーサイクルが`seaborn`に近いものとして，`seaborn-deep`と`seaborn-muted`がある．`seaborn-muted`の方がパステルっぽいというか，明るさがある．`seaborn-deep`が名前通り深みのある色であり，個人的にはこちらが好きだ．

`seaborn`系の中で，幾つか`default`に似たカラーサイクルを持っているものがあり，候補として良い．文字の大きさが変更されるようで，

* `poster` > `talk` > `notebook` > `paper`

という順で文字やマーカーが大きく，線が太い．`default`と`notebook`が同じくらいの文字・マーカーサイズ，線の太さだが，`seaborn`系の方がlegendのボックスの線が細い．

# 終わりに
これが良いという結論は出し辛いので，これで終える．

# Appendix
2Dの図は[以前の投稿](https://qiita.com/ShotaDeguchi/items/c24a89272e651c3de58c)と同様に作成した．

3Dの図はMatplotlibの[3D plotting](https://matplotlib.org/stable/gallery/mplot3d/trisurf3d_2.html#sphx-glr-gallery-mplot3d-trisurf3d-2-py)を基に作成した．

```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as mtri

plt.rcParams['figure.figsize'] = (7, 5)
plt.rcParams['font.family'] = 'Times New Roman'
plt.rcParams['mathtext.fontset'] = 'cm'

fig = plt.figure()

# Make a mesh in the space of parameterisation variables u and v
u = np.linspace(0., 2. * np.pi, endpoint=True, num=50)
v = np.linspace(-.5, .5, endpoint=True, num=10)
u, v = np.meshgrid(u, v)
u, v = u.flatten(), v.flatten()

# This is the Mobius mapping, 
# taking a u, v pair and returning an x, y, z triple
x = (1 + 0.5 * v * np.cos(u / 2.0)) * np.cos(u)
y = (1 + 0.5 * v * np.cos(u / 2.0)) * np.sin(u)
z = 0.5 * v * np.sin(u / 2.0)

# Triangulate parameter space to determine the triangles
tri = mtri.Triangulation(u, v)

# Plot the surface. 
# The triangles in parameter space determine which x, y, z points are connected by an edge.
ax = fig.add_subplot(projection='3d')
C = ax.plot_trisurf(x, y, z, triangles=tri.triangles, cmap="Spectral_r")
fig.colorbar(C, ax=ax, shrink=.6, pad=.1, orientation='vertical', extend='both')

ax.set(
    zlim=(-.5, .5),
    xlabel=r'$x$', 
    ylabel=r'$y$', 
    zlabel=r'$z$'
)

fig.tight_layout()
plt.show()
```