在Python中绘制多条数据线图
我正在阅读一个案例。
对于某个特定的部分,我使用下一个绘图函数在两个点之间画线:
def plotoverline(Xa,Ya,Xb,Yb,Za,Zb,case,index):
PlotOverLine1 = PlotOverLine( Source = "High Resolution Line Source" )
PlotOverLine1.Source.Point1 = [Xa, Ya, Za]
PlotOverLine1.Source.Point2 = [Xb, Yb, Zb]
PlotOverLine1.Source.Resolution = nb_pts
# saving data in CSV File
filename = "case_" + str(case) + "_" + str(index) + ".csv"
writer = CreateWriter(filename)
writer.FieldAssociation = "Points" # or "Cells"
writer.UpdatePipeline()
return filename
我想画多条线,并把每条线的数据导出到一个csv
文件里,但我的代码只写出了第一条线的数据,其他线的数据都是“nan”。
Z = 200 # attitude of my slice
for i in range(le):
Xb = left[i,0]
Yb = left[i,1]
Xa = pt[i,0]
Ya = pt[i,1]
data = plotoverline(Xa,Ya,Xb,Yb,Z,Z,case,ind_left[i])
1 个回答
0
我只需要指定我正在处理的那一部分:plotoverline 函数变成了:
def plotoverline(Slice, Xa,Ya,Xb,Yb,Za,Zb,case,index):
SetActiveSource(Slice)
PlotOverLine1 = PlotOverLine( Source = "High Resolution Line Source" )
PlotOverLine1.Source.Point1 = [Xa, Ya, Za]
PlotOverLine1.Source.Point2 = [Xb, Yb, Zb]
PlotOverLine1.Source.Resolution = nb_pts
# saving data in CSV File
filename = "case_" + str(case) + "_" + str(index) + ".csv"
writer = CreateWriter(filename)
writer.FieldAssociation = "Points" # or "Cells"
writer.UpdatePipeline()
return filename