如何设置LinePlot线条粗细和样式? (DigitalMicrograph脚本)

时间:2014-10-21 06:21:27

标签: line-plot dm-script

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()

1 个答案:

答案 0 :(得分: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的数据点数多于显示的像素数,则可能不会注意到在“'之间定义的线条样式。数据点:

Result of example script

// 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()