Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
用例:比如在 Matplotlib 中绘图。
import numpy as np orig = np.arange(0, 30 + 0.5, 0.5) extra = orig - 0.01 # I'm interested in a few extra values x = np.???(orig, extra)
我想要的是以某种方式合并(我猜当前用例也需要排序)这两个数组(并不总是具有相同的大小),以便我可以将它用于后续绘图?
如果我理解正确,您正在寻找
x = np.sort(np.hstack((orig, extra)))
在这里,hstack()合并两个数组,并对sort()结果进行排序。
hstack()
sort()