1

DigitalMicrograph 的脚本帮助文档提供了一个关于颜色和填充设置 LinePlot 样式的示例(请参见下面的示例脚本)。

但是,LinePlots 的 ImageDisplay 菜单也允许设置线条样式(点线、虚线、...)线条粗细和透明度。有人可以举例说明如何设置这些值吗?

// create image and image document
ImageDocument imageDoc = CreateImageDocument( "New ImageDocument" ) 
number width = 256
number height = 5
image img := RealImage("Line Plot Test", 4, width, height )
img = sin( irow + icol/100 )

// add LinePlotImageDisplay to ImageDocument
ImageDisplay imgdsp = imageDoc.ImageDocumentAddImageDisplay( img, 3 )
imgdsp.LinePlotImageDisplaySetContrastLimits( -1.1, 1.1 )
imgdsp.LinePlotImageDisplaySetDoAutoSurvey( 0, 0 )

// draw fill and line for slice 0
imgdsp.LinePlotImageDisplaySetSliceDrawingStyle(0, 3)
// set line color to red
imgdsp.LinePlotImageDisplaySetSliceComponentColor(0, 0, 1, 0, 0)
// set fill color to yellow
imgdsp.LinePlotImageDisplaySetSliceComponentColor(0, 1, 0.9, 0.9, 0)

// draw fill for slice 1 and 2
imgdsp.LinePlotImageDisplaySetSliceDrawingStyle(1, 2)
imgdsp.LinePlotImageDisplaySetSliceDrawingStyle(2, 2)

// draw line for slice 3 and 4
imgdsp.LinePlotImageDisplaySetSliceDrawingStyle(3, 1)
imgdsp.LinePlotImageDisplaySetSliceDrawingStyle(4, 1)

imageDoc.ImageDocumentShow()
4

1 回答 1

1

您正在寻找的命令是:

  • void LinePlotImageDisplaySetSliceLineThickness( LinePlotImageDisplay lpid, Number slice_id, Number lineThickness )

  • void LinePlotImageDisplaySetSliceLineStyle( LinePlotImageDisplay lpid, Number slice_id, Number lineStyle )

  • void LinePlotImageDisplaySetSliceTransparency( LinePlotImageDisplay lpid, Number sliceIndex, Boolean doTransparent, Number transparency )

它们在下面的示例中进行了演示。请注意,线型的可见性取决于 LinePlot 中的点数。如果 LinePlot 的数据点多于显示的像素,您可能不会注意到线条样式,因为它是在“介于”数据点之间定义的:

示例脚本的结果

// create image and image document
ImageDocument imageDoc = CreateImageDocument( "New ImageDocument" ) 
number width = 64
number height = 10
image img := RealImage("Line Plot Test", 4, width, height )
img = sin( irow + icol / iwidth * 2 * Pi() ) + ( irow < ( height / 2 ) ? 1.5 : -1.5 ) 

// add LinePlotImageDisplay to ImageDocument
ImageDisplay imgdsp = imageDoc.ImageDocumentAddImageDisplay( img, 3 )
imgdsp.LinePlotImageDisplaySetContrastLimits( -2.6, 2.6 )
imgdsp.LinePlotImageDisplaySetDoAutoSurvey( 0, 0 )

// Line style demo
for ( number i = 0 ; i < height / 2 ; i++ )
{
    number index = i + height / 2
    // Set Line - drawing (no fill)
    imgdsp.LinePlotImageDisplaySetSliceDrawingStyle( index , 1 )
    // Set black line
    imgdsp.LinePlotImageDisplaySetSliceComponentColor( index , 0 , 0, 0, 0 )
    // Set LineThickness
    imgdsp.LinePlotImageDisplaySetSliceLineThickness( index , height / 2 - i + 1 )
    // Set LineStyle 
    imgdsp.LinePlotImageDisplaySetSliceLineStyle( index , i )
}

// Transparecny demo
for ( number i = 0 ; i < height / 2 ; i++ )
{
    number index = i 

    // Set Fill & Line - drawing 
    imgdsp.LinePlotImageDisplaySetSliceDrawingStyle( index , 1 + 2 )
    // Set black fill & red line
    imgdsp.LinePlotImageDisplaySetSliceComponentColor( index , 1 , 0 , 0 , 0 )
    imgdsp.LinePlotImageDisplaySetSliceComponentColor( index , 0 , 255 , 0 , 0 )
    // Set transparency ( 70% transparency = 30% opacity )
    imgdsp.LinePlotImageDisplaySetSliceTransparency( index , 1 , 0.7 )
}

imageDoc.ImageDocumentShow()
于 2014-10-21T06:59:28.007 回答