我有一个算法,它自动绘制图形用户界面的绘图区域的数据。下面是我这样做的代码:
self.figure = Figure(figsize=(5,4), dpi=100)
self.graph = self.figure.add_subplot(111)
self.canvas = FigureCanvasTkAgg(self.figure, master=self.root)
self.canvas.show()
self.canvas.get_tk_widget().pack(side=LEFT, fill=BOTH, expand=1)
self.canvas._tkcanvas.pack(fill=BOTH, expand=1)下面是我如何在地块上显示相关的要点:
if eigenvalue > self.eigenvalueThreshold:
if self.previousEigenvalue <= self.eigenvalueThreshold:
main.graph.scatter(windowNumber, eigenvalue, c="red")
else:
main.graph.scatter(windowNumber, eigenvalue, c="yellow")
else:
main.graph.scatter(windowNumber, eigenvalue, c="blue")
self.previousEigenvalue = eigenvalue
main.canvas.show()我得到了这样的信息,在这种情况下,缩放是以数据点集的权重函数自动完成的:

我想知道是否有机会这样绘制我的数据:

你有什么想法吗?
发布于 2014-08-21 18:01:43
对于您想要的,使用fill_between比使用fill更容易。如果您使用fill,您将不得不担心添加眩晕来创建一个封闭的多边形。fill_between自动填充数据与常量值(默认情况下为0)或另一条曲线之间的区域。
例如:
import matplotlib.pyplot as plt
import numpy as np
# Generate some data to plot...
x = np.arange(1000)
y = np.random.normal(0, 1, y.size).cumsum()
y[y < 0] *= -1
fig, ax = plt.subplots()
# Fill the region between your curve and 0 with red...
ax.fill_between(x, y, facecolor='red', edgecolor='none')
# Optional...
ax.grid(True, color='white', linewidth=2, linestyle='-')
ax.set(axisbelow=True, axis_bgcolor='lightgray')
ax.tick_params(direction='out')
plt.show()

发布于 2014-08-21 13:18:17
你可以用( kwargs)。
发布于 2014-08-21 13:53:02
您可能需要使用直方图图:
使用此引用:http://people.duke.edu/~ccc14/pcfb/numpympl/MatplotlibBarPlots.html
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x = np.random.normal(0,1,1000)
numBins = 50
ax.hist(x,numBins,color='green',alpha=0.8)
plt.show()https://stackoverflow.com/questions/25427127
复制相似问题