Skip to content

Commit d037381

Browse files
authored
Update figures-publication.md
1 parent bd19d9d commit d037381

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

matlab/figures-publication.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Preparing figures for publication
22

3-
Here is a summary the most important steps and commands necessary to obtain nice figures of your data that can be imported into the text editing program of your choice.
3+
Here is a summary of the most important steps and commands necessary to obtain nice figures of your data that can be imported into the text editing program of your choice.
44

55
## Scaling
66

@@ -33,9 +33,7 @@ The maximum width for one-column and two-column figures, respectively, is usuall
3333
Here we select the font Times and set the font size to 9.
3434

3535
```matlab
36-
set(fig.Children, ...
37-
'FontName', 'Times', ...
38-
'FontSize', 9);
36+
set(fig.Children, 'FontName', 'Times', 'FontSize', 9);
3937
```
4038

4139

@@ -59,19 +57,25 @@ fig.PaperPositionMode = 'auto';
5957
print('img/my_figure', '-dpng', '-r600')
6058
```
6159

62-
If using vector graphics, `-dpng` can be replaced by `-epsc` for colored eps.
60+
If using vector graphics, `-dpng` can be replaced by `-epsc` for colored eps or `-dsvg`.
6361

6462

6563
## Summary
6664

6765
Here is a simple copy-pastable template:
6866

6967
```matlab
68+
filename = 'something'; % output file name
7069
width = 8; % cm
7170
height = 5; % cm
7271
73-
set(gcf, 'units', 'centimeters', 'position', [0 0 width height])
74-
set(gca, 'LooseInset', max(get(gca,'TightInset'), 0.02))
75-
gcf.PaperPositionMode = 'auto';
76-
print(mfilename, '-dpng', '-r600') % saves figure with the name of the current script
72+
fig.Units = 'centimeters';
73+
fig.Position(3) = width;
74+
fig.Position(4) = height;
75+
set(fig, 'LooseInset', max(get(gca,'TightInset'), 0.02))
76+
set(fig, 'PaperPositionMode','auto', 'PaperUnits','centimeters', 'PaperSize',[fig.Position(3), fig.Position(4)])
77+
print(filename, '-dpng', '-r600') % save as png using 600 dpi resolution
78+
print(filename, '-dtiff', '-r600') % save as svg using 600 dpi resolution
79+
print(filename, '-dpdf', '-r600') % save as pdf using 600 dpi resolution
80+
print(filename, '-dsvg', '-r600') % save as svg using 600 dpi resolution
7781
```

0 commit comments

Comments
 (0)