Python 在处理过程中在白框上绘制图形
我对处理相当陌生,但我已经设法在Python模式下制作了大量GUI。我想在一个白盒子上画一些数据。我不想使用Python 在处理过程中在白框上绘制图形,python,graph,plot,processing,Python,Graph,Plot,Processing,我对处理相当陌生,但我已经设法在Python模式下制作了大量GUI。我想在一个白盒子上画一些数据。我不想使用background(0),因为那样会使整个窗口变白。在draw()函数中使用矩形也没有帮助,因为矩形会不断刷新图形。我试图模拟MATLAB中的保持函数 以下是我的伪代码: class plotEverything: def __init__ def plotAxis def plotGraph def clearGraph def setu
background(0)
,因为那样会使整个窗口变白。在draw()
函数中使用矩形也没有帮助,因为矩形会不断刷新图形。我试图模拟MATLAB中的保持
函数
以下是我的伪代码:
class plotEverything:
def __init__
def plotAxis
def plotGraph
def clearGraph
def setup():
size (800,600)
p1 = plotEverything()
background(0)
def draw():
rect (100,100,200,200)
fill(255)
p1.drawAxis()
p1.plotGraph()
有没有办法把那个长方形固定在背景上
编辑添加的图形类|忽略缩进(假设它们都正确缩进)--
您正在使用什么GUI工具包?
plotAxis
、plotGraph
和clearGraph
做什么?请张贴一个最低限度的例子,再现问题。您提供的代码太有限,我们无法找出问题所在。drawAxis()
和drawGraph()
函数做什么?你能发布一个使用对eliple()
的基本调用的方法吗?不确定我是否理解你,但看起来你想在“清除”其他内容的同时保留一些内容。如果这是案例检查@v.k.我想这正是我要找的。@Mathews_M_J酷,我只是用每个案例的一个简单示例对其进行了编辑。不过,所有这些都是java模式。HTH.:)您正在使用什么GUI工具包?plotAxis
、plotGraph
和clearGraph
做什么?请张贴一个最低限度的例子,再现问题。您提供的代码太有限,我们无法找出问题所在。drawAxis()
和drawGraph()
函数做什么?你能发布一个使用对eliple()
的基本调用的方法吗?不确定我是否理解你,但看起来你想在“清除”其他内容的同时保留一些内容。如果这是案例检查@v.k.我想这正是我要找的。@Mathews_M_J酷,我只是用每个案例的一个简单示例对其进行了编辑。不过,所有这些都是java模式。HTH.:)
class graphData:
def __init__(self, originX, originY, xUpper, yUpper):
self.originX = originX
self.originY = originY
self.xUpper = xUpper
self.yUpper = yUpper
self.pointX1 = originX
self.pointX2 = xUpper
self.pointY1 = originY
self.pointY2 = yUpper
self.scaleFactorX = 10.0/(xUpper - originX) #Assuming data is between is 0 and 10
self.scaleFactorY = 10.0/(originY - yUpper) #Assuming data is between is 0 and 1
def drawAxis(self):
stroke(255)
strokeWeight(1.5)
line(self.originX, self.originY, self.originX, self.yUpper) #y axis
line(self.originX, self.originY, self.xUpper, self.originY) #x axis
def plotStaticData(self,data2Plot): #X-axis static
ab = zip(data2Plot,data2Plot[1:],data2Plot[2:],data2Plot[3:])[::2]
if ab:
(X1,Y1,X2,Y2) = ab[-1]
print (X1,Y1,X2,Y2)
self.pointX1 = self.originX + ceil((float(X1) - 0.0)/self.scaleFactorX)
self.pointX2 = self.originX + ceil((float(X2) - 0.0)/self.scaleFactorX)
self.pointY1 = self.originY - ceil((float(Y1) - 0.0)/self.scaleFactorY)
self.pointY2 = self.originY - ceil((float(Y2) - 0.0)/self.scaleFactorY)
stroke(255)
strokeWeight(2.0)
line(self.pointX1,self.pointY1,self.pointX2,self.pointY2)
def clearPlot(self):
background(0)
self.drawAxis()