比方說,我們有一個列表,其中包含另一個列表與一些數據,在我的情況下,頻率。如何繪製穩定圖?
model_order = [[],
[1],
[1.1],
[1, 1.5],
[1, 1.55, 3.5],
[1.1, 1.45, 3.45, 3.5, 4.8]]
正如您所看到的,嵌套列表具有不同的長度,也可以爲空。
我要繪製像on the picture圖,
而是停留在如何使用python和matplotlib做到這一點。我該怎麼做? (1,len(model_order [i]),len(model_order [ i]))作爲x軸的數據。但是對於具有相同第一維度的x和y數據的必要條件。
from matplotlib import pyplot
import numpy as np
def plot_stabilization_diagram(data):
pyplot.figure(figsize=(8, 6), dpi=80)
pyplot.subplot(1, 1, 1)
yaxis = np.linspace(1, len(data), len(data))
for d in xrange(len(data)):
pyplot.plot(data[d], yaxis, 'o')
pyplot.show()
>>> ValueError: x and y must have same first dimension
你能告訴我們你已經嘗試了什麼?這寫作'請爲我做我的工作',這往往會惹惱人們。 – tacaswell