在圖表中嵌入資料表的圖片。
@Neo問是否可以從打開的表中獲取行和列作為圖表的插入?
fontscale = 2; // scale up as needed. make the font bigger to make the image bigger.
picScale = .42; // scale down to fit. less than one to prevent pixelation.
topFraction = 0.95; // 0 at bottom, 1 at top of frame
bottomFraction = 0.05; // 0 at left, 1 at right of frame
dt = Open( "$sample_data/big class.jmp" );
// take a picture of the data
box = dt << journal;
oldFont = Get Preferences( fonts );
Preferences( Fonts( English( Text Font( "Segoe UI", 9 * fontscale ), Heading Font( "Segoe UI", 12 * fontscale, "Bold" ), ) ) );
pic = box << getpicture;
{xPixPixels, yPicPixels} = pic << size;
box << closewindow;
Eval( oldFont );
// make the graph
gb = Graph Builder(
Show Control Panel( 0 ),
Size( 1158, 894 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
// add the image
{xFramePixels, yFramePixels} = (Report( gb )[FrameBox( 1 )]) << getsize;
xmin = (Report( gb )[axisBox( 1 )]) << getmin;
xmax = (Report( gb )[axisBox( 1 )]) << getmax;
xUnitsPerPixel = (xmax - xmin) / xFramePixels;
ymin = (Report( gb )[axisBox( 2 )]) << getmin;
ymax = (Report( gb )[axisBox( 2 )]) << getmax;
yUnitsPerPixel = (ymax - ymin) / yFramePixels;
topPos = ymin + (ymax - ymin) * topFraction;
leftPos = xmin + (xmax - xmin) * bottomFraction;
bottomPos = topPos - picScale * yPicPixels * yUnitsPerPixel;
rightPos = leftPos + picScale * xPixPixels * xUnitsPerPixel;
(Report( gb )[FrameBox( 1 )]) << Add Image( image( pic ), bounds( top( topPos ), Left( leftPos ), bottom( bottomPos ), Right( rightPos ) ) );
// clean up. this will capture a picture and close the report and data table
gb << savepicture( "$temp/example.png" );
gb << closewindow;
Close( dt, nosave );
Open( "$temp/example.png" );
A picture of a journaled data table embedded in a graph.嵌入圖表中的日誌資料表的圖片。
如果右鍵單擊->自訂圖表,您可以看到圖像的預設行為將它們放在圖表後面。
The list items are drawn in order from top to bottom (painter's algorithm.) The picture is below the graph.列表項目以從上到下的順序繪製(畫家演算法)。
您可以將要繪製的圖片移到圖表之後,但這通常是不可取的。
The picture has a solid white background that blocks the graph.這張圖片具有純白色背景,遮住了圖形。
我知道這有點偏離原來的主題,但 JMP 是否考慮過在圖形生成器中添加單調平滑器?對於這種情況,我們非常清楚關係應該是單調的,這將是一個不錯的選擇。