DeprecationWarning:为数组排序检测到非字符串对象。请改为输入“ C”,“ F”,“ A”或“ K”

use*_*801 6 python 3d

from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot

# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)

# Load the STL files and add the vectors to the plot
your_mesh = mesh.Mesh.from_file("/home/niroz/stl files/bottle/binary.stl")

axes.add_collection3d(mplot3d.art3d.Poly3DCollection(your_mesh.vectors))

# Auto scale to the mesh size
scale = your_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)

# Show the plot to the screen
pyplot.show()
Run Code Online (Sandbox Code Playgroud)

pon*_*dto 5

您的代码假设旧版本的numpy.

较新版本numpy(我的是 1.14.0)您可以通过键入检查 IPython 中的文档字符串

np.ndarray.flatten?
Run Code Online (Sandbox Code Playgroud)

我得到的是:

Docstring:
a.flatten(order='C')

Return a copy of the array collapsed into one dimension.

Parameters
----------
order : {'C', 'F', 'A', 'K'}, optional
    'C' means to flatten in row-major (C-style) order.
    'F' means to flatten in column-major (Fortran-
    style) order. 'A' means to flatten in column-major
    order if `a` is Fortran *contiguous* in memory,
    row-major order otherwise. 'K' means to flatten
    `a` in the order the elements occur in memory.
    The default is 'C'.
Run Code Online (Sandbox Code Playgroud)

相当于传递-1'F'选项,即以下代码段:

import numpy as np

foo = np.array([[1,2,3], [3,4,5]])
print (foo.flatten(-1) == foo.flatten('F')).all()
Run Code Online (Sandbox Code Playgroud)

产生True(以及DeprecationWarning你要问的)。