5

matplotlib を使用して 3D 散布図を作成していますが、3 つの軸すべてに共通の原点を持つ図を作成できません。これどうやってするの?

私のコード(これまでのところ)、私はPythonに非常に慣れていないため、軸仕様の定義を実装していません:

  from mpl_toolkits.mplot3d.axes3d import Axes3D
  import matplotlib.pyplot as plt


  # imports specific to the plots in this example
  import numpy as np
  from matplotlib import cm
  from mpl_toolkits.mplot3d.axes3d import get_test_data

  def randrange(n, vmin, vmax):
  return (vmax-vmin)*np.random.rand(n) + vmin

  # Same as wide as it is tall.
  fig = plt.figure(figsize=plt.figaspect(1.0))


  ax = fig.add_subplot(111, projection='3d')

  n = 512

  xs = np.random.randint(0, 10, size=n)
  ys = np.random.randint(0, 10, size=n)
  zs = np.random.randint(0, 10, size=n)
  colors = np.random.randint(0, 10, size=n)
  scat = ax.scatter(xs, ys, zs, c=colors, marker='o')

  ax.set_xlabel('X Label')
  ax.set_ylabel('Y Label')
  ax.set_zlabel('Z Label')


  fig.colorbar(scat, shrink=0.5, aspect=10)

  plt.show()
4

2 に答える 2

0

ラインを入れると

ax.view_init(30,220)

直前

plt.show()

xy平面に必要なものを取得する必要があります。その平面をz = 0に移動する方法についてはわかりません。

于 2014-11-25T17:39:27.070 に答える