我想將圖像添加到 JMP 表中,因此當我將鼠標懸停在數據點上時,我可以看到關聯的圖像。 我擔心的是我的表有 300,000 多行,我認為如果我向每一行添加圖像,文件大小可能會變得難以管理。 然而,許多行將共享相同的圖像 - 只有約 30,000 個圖像,每個圖像由約 10 行共享。 有沒有一種有效的方法可以在不增加文件大小的情況下將圖像與多行關聯? (或者 JMP 是否已經知道自動執行此操作?)
作為參考,以下是我之前用於將圖像添加到 JMP 表的代碼,儘管在這種情況下,每一行都會獲得不同的圖像。
Names Default to Here(1);
// run the script on the currently-selected data table
dt = Current Data Table();
// point to the directory where your thumbnail images are stored
// this script assumes the image names follow the pattern "0001.jpg", "0002.jpg", etc.
BaseImageDirectory = "C:\Users\user\Downloads\thumbnails\";
// create a column called "pics" to put the images
CurrentColumnNames = dt << get column names(string);
if (!contains(CurrentColumnNames, "pics"), New Column("pics", Expression));
// iterate through each row in the data table to add the images
For Each Row(
// look for a column called "image_directory" and take the name of the lowest-level subdirectory
Directory = word(-1, :image_directory, "\");
// zero-pad the image number to four digits (e.g. image_number 1 becomes 0001)
ImageID = Repeat( "0", 4 - Length( Char( :image_number ) ) ) || Char( :image_number );
// look for a file name like 0001.jpg in a folder with a name matching "image_directory"
ThumbnailFile = BaseImageDirectory || Directory || "\" || ImageID || ".jpg";
Eval(Eval Expr(tp = ThumbnailFile));
// insert the image into the column "pics"
Try(dt:pics = new image(tp));
);
// set "pics" as a label so it shows up when you hover over any data point
dt:pics << label(1);我會將每個唯一圖像的單個副本放入一個數據表中,然後通過將大型數據錶鍊接到圖像表來創建一個虛擬表,從而避免重複。
其他選項可能是使用懸停標籤並僅在需要時加載圖像。 在這種情況下,您可以將路徑存儲到數據表,然後使用懸停標籤根據這些路徑加載這些路徑。