MATLAB Answers

How to add thumbnail to a .fig file in Windows 10?

5 views (last 30 days)
Chaitanya Jha
Chaitanya Jha on 29 Mar 2019
Commented: Chaitanya Jha on 3 Apr 2019
Hi, I am developing a software for Electrophysiology. In this software I do several Voltage and Current recording from cells such as neurons. In each recording there are multiple Voltage and Current plot lines in a single axis. I want to save these recordings in a figure file which when opened provides a group of checkboxes to select any number of these plot lines to be shown on its axis. I want to save these figure files with the thumbnaill showing the axis plot in winodws 10 (just like it happens with a picture where you have a thumbail showing the picture). Any ideas on how to achieve this?


Jan on 29 Mar 2019
Please provide picture of what you want. Why do you need checkboxes, when you can select the axes directly?
The question is quite general yet. What have you tried so far? How exactly can we help you?
Chaitanya Jha
Chaitanya Jha on 2 Apr 2019
Hi Jan,
Below is a picture of what I save on each recording. Each recording creates multiple voltage and current line plots. Each recording is saved in a .fig file in folder. Each of these .fig files have checkboxes to select which line plots are shown. I can open these recording anytime and select which line plots are shown using the checkboxes on the left. There are 100s of recordings like this taken in a single day.
I need the checkboxes so that I can individually select which line plot is shown on axis, since lots of line plots are overlapping and not all of these are useful for data analysis.
I need the picture of axis to have as thumbnail of the figure file, this is so that I can just view the thumbnail and see what plots it has. SInce there are hundreds of these plots created in a single day (so that means hundreds of these individual files each having many line plots) opening each one to view what kind of plot it contains is a big waste of time. Based on thumbnail I can easily see which of the plots is useful and open only that one.
Till now I can create this figure and add the line plots to it. Everything is working fine except for the thumbnail. When these files are saved it has the default thumbnail of Matlab Figure file and hence all files look the same in the folder where they are saved.
I have researched about creating the thumbnail, and with my research this is what I know:
Windows only allows .ico files to be used as thumbnail and Matlab can read .ico files but cannot export them, this means I can't save the image of axis as .ico using Matlab. What I can do is save the image of axis as .png and export it to windows then upload it to a png to ico converter website to get it as .ico file. Then other part of the problem is Windows doesn't allow me to change individual thumbnails of the Matlab figure files, so to overcome this problem I can create a shortcut with the .ico as its thumbnail and link that shortcut to the given figure file. However, this is a long solution and far from a perfect one, especially since all this is supposed to happen automatically in the background while the experiment is being performed. I am hoping to find a better solution.
If you can guide me to somehow change the thumbnail of each individual figure files using matlab that will be great. I am even ready to create my own custom extension for saving each individual figure files.

Sign in to comment.

Accepted Answer

Jan on 3 Apr 2019
The approach to use the thumbnail of the image in the Windows Explorer is rather indirect. This is not the purpose of the Windows Explorer, although the thumbnail selection is implemented e.g. for JPG images.
What about using a tool, which does exactly, what you want? You can export a screenshot of the figure as PNG and display a list of them in another figure. The callback of each image opens the correponding FIG file.
for k = 1:4
Fig(k) = figure;
image(rand(10, 10));
print(Fig(k), fullfile(tempdir, sprintf('Fig%d.png', k)), '-dpng');
savefig(Fig(k), fullfile(tempdir, sprintf('Fig%d.fig', k)), '-compact')
DlgH = figure;
for k = 1:4
thumb = imread(fullfile(tempdir, sprintf('Fig%d.png', k)));
AxesH(k) = subplot(2, 2, k, 'Visible', 'off');
image(AxesH(k), thumb, 'ButtonDownFcn', ...
{@myOpen, fullfile(tempdir, sprintf('Fig%d.fig', k)})
function myOpen(ImageH, EventData, FigFile)
The dialog can be adjusted easily to be scrollable vertically and/or horizontally. You can adjust the size and number fo the subplots, show a larger preview etc. This is much simpler than using the Windows Explorer for something, which it is not designed to do.

  1 Comment

Chaitanya Jha
Chaitanya Jha on 3 Apr 2019
I think this is the most eligant and simple solution. Also here I will be able to implement buttons such as to delete the figure next to each png image without opening the figure file. I will implement it in this way. Thanks for the help :)

Sign in to comment.

More Answers (0)

Sign in to answer this question.