繪製 3D 圖你好,
我正在嘗試繪製 3D 圖但未成功。 我在Excel中有這樣的資料:
| | 是 | 4,15815757 | 10,5410784 |
| X | | Z1 | Z2 |
| 0,00038225 | | 0,04740562 | 0,09242527 |
| 0,00032384 | | 0,13448339 | 0,34250103 |
但我有很多行和列。 這只是一個例子。 我將不勝感激任何幫助。
謝謝。
回覆:繪製 3D 圖「Datan.xlsx」有 23 個 Y 值、444 個 X 值和每個 Z 值(總共 10212 個值)。 所以 'dtFinal' 不應該是:
dtFinal = New Table( "Converted", New Column( "X" ), New Column( "Y" ), New Column( "Z" ) );
dtFinal << add rows( N Rows( Xmat ) * N Rows( Ymat ) );
rowcnt = 0;
For( Xcnt = 1, Xcnt <= N Rows( Xmat ), Xcnt++,
For( Ycnt = 1, Ycnt <= N Rows( Ymat ), Ycnt++,
rowcnt++;
dtFinal:X[rowcnt] = Xmat[Xcnt];
dtFinal:Y[rowcnt] = Ymat[Ycnt];
dtFinal:Z[rowcnt] = Zmat[Xcnt, Ycnt];
)
);
給予類似的東西?

在不了解資料上下文和您正在嘗試的內容的情況下,我認為可以提供更多資訊的視覺化。
回覆:繪製 3D 圖該代碼運行得很好。 我發現我沒有足夠的記憶體來運行所有行104,284,944 ,這就是它沒有運行的原因。
我正在使用 JMP 12。
非常感謝。
回覆:繪製 3D 圖我下載了你的 Excel 檔案並儲存了它。然後我將 JSL 腳本指向新檔案。我還必須更改程式碼中的行
Worksheets( "example" ),
到
Worksheets( "JMP" ),
因為您更改了工作簿中電子表格的名稱。
我沒有將程式運行到 JSL 在運行完成時將生成的完整 104,284,944 行,但我確實將其運行到較少的行數,以向自己證明程式碼可以工作。
如果上述更改不是問題,那麼我的下一個問題是,您使用的是哪個版本的 JMP?
回覆:繪製 3D 圖非常感謝您的幫助,我真的很感激。
但是,當我執行該腳本時,它在第 70 行顯示錯誤,指出無法確定 X 列中的值,因為行數 (0) 無效。
我附上了我正在處理的 Excel 資料。 您介意看一下嗎? 我是 JSL 的新用戶,所以我沒有太多經驗。
謝謝。
回覆:繪製 3D 圖我的第一個建議是將 Add Rows() 向上移動到循環中。Add Rows() 是一個非常緩慢的函數,因此如果您可以將資料表所需的所有行新增至初始 New Table() 之後,這將使程式更快。這也意味著您必須新增一個整體行計數器,以追蹤您正在處理的行,而不是使用 N Rows()。
Names Default To Here( 1 );
// Read in Excel file
dt = Open(
"c:\users\txjim\documents\read in issue\example.xlsx"
/*"<YOUR path="" to="" the="" excel="" file="">\example.xlsx"*/,
Worksheets( "example" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 0 ),
,
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 1 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// Get Y Matrix
Ymat = {};
For( i = 3, i <= N Col( dt ), i++,
If( Column( i )[1] != "",
Ymat = Ymat |/ Matrix( Num( Column( i )[1] ) )
)
);
// Get rid of unrequired cells, and get the X and Z matrices
dt << select rows( [1, 2, 3] );
dt << delete rows;
dt << delete column( 2 );
// Convert all columns to numerics
For( i = 1, i <= N Col( dt ), i++,
Column( dt, i ) << data type( numeric )
);
// Get X matrix
Xmat = Column( dt, 1 ) << get as matrix;
dt << delete column( 1 );
// Get Z matrix
Zmat = dt << get as matrix;
// Create new data table, and output the data
dtFinal = New Table( "Converted", New Column( "X" ), New Column( "Y" ), New Column( "Z" ) );
dtFinal << add rows( N Rows( Xmat ) * N Rows( Ymat ) * N Rows( Zmat ) * N Cols( Zmat ) );
rowcnt = 0;
For( Xcnt = 1, Xcnt <= N Rows( Xmat ), Xcnt++,
For( Ycnt = 1, Ycnt <= N Rows( Ymat ), Ycnt++,
For( Zrowcnt = 1, Zrowcnt <= N Rows( Zmat ), Zrowcnt++,
For( Zcolcnt = 1, Zcolcnt <= N Cols( Zmat ), Zcolcnt++,
rowcnt++;
dtFinal:X[rowcnt] = Xmat[Xcnt];
dtFinal:Y[rowcnt] = Ymat[Ycnt];
dtFinal:Z[rowcnt] = Zmat[Zrowcnt, Zcolcnt];
)
)
)
);
dtFinal << Scatterplot 3D(
Y( :X, :Y, :Z ),
Frame3D(
Set Grab Handles( 0 ),
Set Walls( 1 ),
Set Rotation( -54, 0, 38 ),
Set Text Scale( 2 ),
Set Line Scale( 1 ),
Set Marker Transparency( 1 ),
Set Marker Quality( 0.25 ),
Set Marker Scale( 1 ),
Set View Perspective( 0.1 ),
Set View Zoom( 1 )
)
);</YOUR>回覆:繪製 3D 圖我還有一個問題。 有沒有辦法讓這段程式碼運行得更快,因為我正在處理大數據,需要幾個小時才能運行,有時卻不會。
我的筆記型電腦是華碩、Windows 7、64 位元、4GB (RAM) 和 197GB 記憶體。
所以我不認為問題出在我的電腦上,對嗎?
謝謝。
回覆:繪製 3D 圖非常感謝。 這正是我想做的,而且效果非常好。
回覆:繪製 3D 圖我根據您的描述建立了一個範例 Excel 文件,並將其附加到此條目中。然後,我開發了以下 JSL 來讀取它,並建立資料的 3D 繪圖。我希望這是你想要的

Names Default To Here( 1 );
// Read in Excel file
dt = Open(
"<YOUR path="" to="" the="" excel="" file="">\example.xlsx",
Worksheets( "example" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 0 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 1 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// Get Y Matrix
Ymat = {};
For( i = 3, i <= N Col( dt ), i++,
If( Column( i )[1] != "",
Ymat = Ymat |/ Matrix( Num( Column( i )[1] ) )
)
);
// Get rid of unrequired cells, and get the X and Z matrices
dt << select rows( [1, 2, 3] );
dt << delete rows;
dt << delete column( 2 );
// Convert all columns to numerics
For( i = 1, i <= N Col( dt ), i++,
Column( dt, i ) << data type( numeric )
);
// Get X matrix
Xmat = Column( dt, 1 ) << get as matrix;
dt << delete column( 1 );
// Get Z matrix
Zmat = dt << get as matrix;
// Create new data table, and output the data
dtFinal = New Table( "Converted", New Column( "X" ), New Column( "Y" ), New Column( "Z" ) );
For( Xcnt = 1, Xcnt <= N Rows( Xmat ), Xcnt++,
For( Ycnt = 1, Ycnt <= N Rows( Ymat ), Ycnt++,
For( Zrowcnt = 1, Zrowcnt <= N Rows( Zmat ), Zrowcnt++,
For( Zcolcnt = 1, Zcolcnt <= N Cols( Zmat ), Zcolcnt++,
dtFinal << Add Rows( 1 );
dtFinal:X[N Rows( dtFinal )] = Xmat[Xcnt];
dtFinal:Y[N Rows( dtFinal )] = Ymat[Ycnt];
dtFinal:Z[N Rows( dtFinal )] = Zmat[Zrowcnt, Zcolcnt];
)
)
)
);
dtFinal << Scatterplot 3D(
Y( :X, :Y, :Z ),
Frame3D(
Set Grab Handles( 0 ),
Set Walls( 1 ),
Set Rotation( -54, 0, 38 ),
Set Text Scale( 2 ),
Set Line Scale( 1 ),
Set Marker Transparency( 1 ),
Set Marker Quality( 0.25 ),
Set Marker Scale( 1 ),
Set View Perspective( 0.1 ),
Set View Zoom( 1 )
)
);</YOUR>
請務必將 JSL 中的路徑變更為指向儲存附加 Excel 檔案的位置
回覆:繪製 3D 圖謝謝您的回覆。 我將向您展示我的資料在 Excel 中的樣子:
| | 是 | 4,15815757 | 10,5410784 | 14,6453847 | 19,762652 | 29,5884633 | 40,1035851 | 52,7727379 | 64,5664014 | 71,6339866 | 80,1791963 | 92,5639742 | 108,325272 | 114,711013 | 121,815695 | 142,186092 | 160,139901 | 175,938007 | 189,208612 | 200,409857 | 209,675249 | 221,03791 | 241,182479 | 256,870356 |
| X | | Z1 | Z2 | Z3 | Z4 | Z5 | Z6 | Z7 | Z8 | Z9 | Z10 | Z11 | Z12 | Z13 | Z14 | Z15 | Z16 | Z17 | Z18 | Z19 | Z20 | Z21 | Z22 | Z23 |
| 0 | | | | | | | | | | | | | | | | | | | | | | | | |
| -3,8225E-05 | | 0,04740562 | 0,09242527 | 0,23259929 | 1,38211141 | 2,04180178 | 3,06816231 | 0,27673071 | 0,08808252 | 0,85756483 | 0,11511972 | 0,39746555 | 0,22290737 | 0,06869082 | 0,48405979 | 1,49275933 | 0,64964997 | 0,85255862 | 2,7009082 | 0,92420938 | 0,07121721 | 20,393539 | 12,7535737 | 2,59458619 |
| 0,00032384 | | 0,13448339 | 0,34250103 | 0,37990033 | 0,38410363 | 1,70627509 | 0,89349347 | 0,42177943 | 0,20623338 | 1,51917679 | 0,26283727 | 0,68063752 | 0,75284843 | 0,10052593 | 0,3008461 | 0,98138204 | 1,02336837 | 0,31897393 | 1,47302568 | 0,78544606 | 0,1680408 | 0,3350895 | 1,47171341 | 7,46166212 |
下面您可以看到我的資料在 X、Y、Z 形式中的樣子,但我有來自 Y 的 23 個點和數百行。
| y | y1 | y2 | y3 | y4 |
| x1 | z11 | z21 | z31 | z41 |
| x2 | z12 | z22 | z32 | z42 |
我想在一張 3D 圖中顯示座標。
這就是問題所在,因為為了在顯示的表格 XYZ 中向您展示,我必須擴展這個矩陣。 例如:
| x1 | y1 | z11 |
| x1 | y1 | z12 |
| x1 | y1 | z13 |
| | | |
| x1 | y2 | z21 |
| x1 | y2 | z22 |
| x1 | y2 | z23 |
等等.. 但我不知道如何在 JMP 中執行此操作並繪製它。 我知道有一種使用 Origin 自動執行此操作的方法,但我需要使用 JMP 執行此操作。 你能明白我的意思嗎?
謝謝。
回覆:繪製 3D 圖需要對您的數據進行更多解釋。
您是否期望所有數據都顯示在一個圖表中,或者每個 Z 列、Z2、Z2 等表示要製作單獨的圖表?
由於 3D 繪圖中的每個顯示點都是由 3 個維度定義的,您能否說明一下,如果表格採用以下形式,則顯示表格中的值將如何顯示:
回覆:繪製 3D 圖通常,JMP 平台希望每個變數(在本例中為「x」、「y」和「z」)的值位於其自己的欄位中。 因此,對於您的數據,我認為這將是:

然後你可以嘗試,例如“圖表> 3D 散點圖'。
您也可以使用 JMP 手動或使用腳本將資料重新排列成這種形狀。 但詳細資訊取決於您如何從 Excel 中讀取它。