This week it was my turn to present at the MRG seminar and I wanted to do something different from what we did so far. So, I decided to do a webinar/tutorial on:

*“How to easily convert your figures into high-resolution in a few steps”*

*Changing the size & resolution of your images for publication (e.g., papers, posters…)*

***

This post is the result of the webinar and it will be focused on three different levels depending on the software to be used (all available in MyApps from UPF or open-source):

**Seed-level**(MATLAB)**Sprout-level**(MATLAB + PowerPoint)**Plant-level**(MATLAB + PowerPoint + Gimp)

Here we go!

### Ground-level

Before we start, I would like to show how I generate the figure we’ll use along the tutorial and what’s the resolution by default MATLAB uses to save the figures.

First of all, we will generate a cosine function using the following code:

% Creating a cosine function t = pi/2:(2*pi/10):(2*pi+pi/2); x = cos(t);

We will plot the cosine with these lines:

% Figure (directly saved at 300 dpi & .tiff) figure1 = figure('Color','w','NumberTitle','off'); % make blank figure set(gcf, 'Position', get(0,'Screensize')); plot(t,x,'o', 'MarkerSize',18, 'Color',[0 0 0],'LineWidth',3); hold on; set(gca,'FontSize',20); plot(t(2),cos(t(2)),'MarkerFaceColor',[.1 .5 .5],'MarkerSize',26,... 'Marker','o', 'Color',[0 0 0], 'LineWidth', 3); plot(t(7),cos(t(7)),'MarkerFaceColor',[.75 0 .25],'MarkerSize',26,... 'Marker','o', 'Color',[0 0 0],'LineWidth', 3); xlabel('Phase bins [in degrees]'); xlim([0 2*pi+pi]); ylim([-1.5 1.5]); ylabel({'- Reaction Time +'}); set(gca,'FontSize',30,'XTick',[],'YTick',[]); % Set the remaining axes properties

And save the figure in default resolution and *.png* format:

% Save figure wpfilename_fig = ('original.fig'); wpfilename_png = ('original'); savefig(wpfilename_fig); print(wpfilename_png, '-dpng');

Here’s the resulting figure:

If we open the figure with Gimp, we can see that the resolution is 150 DPI:

Let’s see different-level methods to change the resolution of the figures with a very few steps.

**Seed-level (**MATLAB)

#### When and why to use this level?

- Want to use a unique program
- You have very simple figures
- You want everything coded (no interaction with GUIs/programs)
- You want it to be an automated and optimized process
**You have very simple figures**- No need for editing or merging figures

#### Tutorial

First of all, we will generate a cosine function using the following code:

% Creating a cosine function t = pi/2:(2*pi/10):(2*pi+pi/2); x = cos(t);

We will plot the cosine with these lines:

% Figure (directly saved at 300 dpi & .tiff) figure1 = figure('Color','w','NumberTitle','off'); % make blank figure set(gcf, 'Position', get(0,'Screensize')); plot(t,x,'o', 'MarkerSize',18, 'Color',[0 0 0],'LineWidth',3); hold on; set(gca,'FontSize',20); plot(t(2),cos(t(2)),'MarkerFaceColor',[.1 .5 .5],'MarkerSize',26,... 'Marker','o', 'Color',[0 0 0], 'LineWidth', 3); plot(t(7),cos(t(7)),'MarkerFaceColor',[.75 0 .25],'MarkerSize',26,... 'Marker','o', 'Color',[0 0 0],'LineWidth', 3); xlabel('Phase bins [in degrees]'); xlim([0 2*pi+pi]); ylim([-1.5 1.5]); ylabel({'- Reaction Time +'}); set(gca,'FontSize',30,'XTick',[],'YTick',[]); % Set the remaining axes properties

And save the figure in *300 dpi* and *.fig* and *.tiff* formats:

% Save figure wpfilename_fig = strcat(pnum,'_original.fig'); wpfilename_png = strcat(pnum,'_original'); % '.fig' format savefig(wpfilename_fig); % '.png' format print(wpfilename_png, '-dpng', '-r300'); % '.tiff' format print(gcf, '-dtiff', 'seedlevel.tiff', '-r300');

Here’s the result when looking at the resulution of the figure:

#### But…

- What happens when we have multiple individual-level plots?
- What if we want to merge them in a unique figure?
- What happens if we want to change details of the figure
*(e.., adding a legend, changing the x.label, adding title…)*?

#### Caveats

- There’s no much room for changes
- Costly (re-do figure again and again)
- MATLAB is not an editing program
- Not well oriented for non-programers

**Sprout-level (**MATLAB + PowerPoint)

#### When and why to use this level?

- You want to make your life easier with
*PowerPoint* - Editing in
*PowerPoint*is really handy and easy - Changing resolution while remaining at “code-level”
- Well-fitted if you have very little time (shortcut)
- You prefer to use programs that you already know

#### Tutorial

The idea here is to create the images in MATLAB and then merging them in PowerPoint (e.g., multi-plot with indiviudal-level figures). So, when you save the image in PPT it’s in high-resolution. You can do that by following the steps explained below:

- Write ‘
*regedit*‘ in the Windows browser and open the*registry editor*.

- Create a new decimal value (DWORD) under the name ‘
*ExportBitmapResolution*‘ and enter the resulition value you want (e.g., 300).

Now, if you save the slide of the PowerPoint you’ll have the images in the resolution that you want and save it any format you wish (e..g, .png, .tiff…).

#### But…

- What happens if we want to work in different layers?
- What happens if we to do something more sophisticated?

#### Caveats

*PowerPoint*is for presentations, not editing*PowerPoint*is very limited in terms of editing

**Plant-level ****(**MATLAB + PowerPoint + Gimp)

#### When and why to use this level?

- Simplify the process
- Creating the figures in MATLAB and editing in
*PowerPoint* - Change figure resolution in a few clicks with
*Gimp* - If time is not on your side

#### Tutorial

You can also change the resolution in Gimp in a few clicks:

- Go to
*Image > Scale image…*

- Change the value of X resolution (or Y resolution) to the one you prefer (e.g., 300 dpi or pixels/in) and click ‘
*Scale*‘.

#### Caveats

- Oooops… Error 404 not found.

### Alternatives

You can also have a look at:

- ggplot for R studio.
- gramm and notBoxPlot toolboxes for MATLAB

Hope you find it useful and make nice high-resolution figures from now on!

#### Sources

Feature image from Pexels – C0 license.