例如,我使用以下命令生成数据:
i=0; while [ "$i" -lt 10 ]; do echo "$i,$((2*i)),$((4*i))"; i=$((i+1)); done > main.csv
其中包含:
0,0,0
1,2,4
2,4,8
3,6,12
4,8,16
5,10,20
6,12,24
7,14,28
8,16,32
9,18,36
然后例如在gnuplot中,我用palette
得到了想要的东西:
#!/usr/bin/env gnuplot
set terminal png size 1024,1024
set output "main.png"
set datafile separator ","
set key off
plot "main.csv" using 1:2:3 palette pt 7 pointsize 10
给出所需的内容:
如何使用Paraview达到这种效果?
我设法使用折线图视图制作散点图,但是所有点都是红色的,像这样:
我也无法调整标记大小,但是为此我发现了一个未解决的问题:https://gitlab.kitware.com/paraview/paraview/issues/14169
我最初是在学习用于绘制图形的GUI,但是如果您有一个脚本选项也很了解的话。
在Ubuntu 18.10,Paraview 5.4.1中进行了测试。
答案 0 :(得分:1)
这是python脚本,用于读取文件并在ParaView 3D渲染视图中显示标记。
import paraview.simple as pvs
# create a new 'CSV Reader'
csvReader = pvs.CSVReader(FileName=['C:\\your_file.csv'])
csvReader.HaveHeaders = 0
# create a new 'Table To Points'
tableToPoints = pvs.TableToPoints(Input=csvReader)
tableToPoints.XColumn = 'Field 0'
tableToPoints.YColumn = 'Field 1'
tableToPoints.ZColumn = 'Field 2'
tableToPoints.KeepAllDataArrays = 1
tableToPoints.a2DPoints = 1
# create a new 'Glyph'
glyph = pvs.Glyph(Input=tableToPoints, GlyphType='Arrow')
glyph.Scalars = ['POINTS', 'Field 0']
glyph.Vectors = ['POINTS', 'None']
glyph.GlyphType = '2D Glyph'
glyph.GlyphType.GlyphType = 'Square'
glyph.GlyphType.Filled = 1
glyph.ScaleMode = 'off'
glyph.ScaleFactor = 1.0
glyph.GlyphMode = 'All Points'
### uncomment to scale markers by 'Field 2'
# glyph1.Scalars = ['POINTS', 'Field 2']
# glyph1.ScaleMode = 'scalar'
# show data in view
renderView = pvs.GetActiveView()
glyphDisplay = pvs.Show(glyph, renderView)
glyphDisplay.Representation = 'Surface'
pvs.ColorBy(glyphDisplay, ('POINTS', 'Field 2'))
glyphDisplay.SetScalarBarVisibility(renderView, True)
glyphDisplay.RescaleTransferFunctionToDataRange(True, False)
renderView.Update()
pvs.UpdatePipeline()
renderView.AxesGrid.Visibility = 1
renderView.ResetCamera()
pvs.Render(renderView)