19
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python 3次元グラフのテーマカラー,グラフの表示角度を変更

Last updated at Posted at 2018-12-09

##準備
サンプルとして用いる3次元グラフを生成.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
 
x = np.arange(-10, 10, 0.1)
y = np.arange(-10, 10, 0.1)
X, Y = np.meshgrid(x, y)
Z = np.sin(X + Y)

ax.plot_surface(X, Y, Z)

Unknown.png

##テーマカラーの変更

cm.'指定するテーマカラー'という感じでテーマカラーを指定します.
今回はoceanを指定していますが,他にも多数のテーマがあります.
詳しくは以下のページを参照してください.
matplotlib color example code

ax.plot_surface(X, Y, Z, cmap='ocean') 

Unknown-1.png

##表示角度の変更

elevはz軸方向から見た仰角,azimはx, y軸方向の方位角を指定.
詳しくは以下を参照してください.
matplotlib mplot3d API

ax.view_init(elev=60, azim=45)

Unknown-2.png

19
22
3

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
19
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?