[texhax] How to create legend in Latex

Torsten Wagner torsten.wagner at gmail.com
Tue Nov 2 06:24:41 CET 2010


Hi Mostafa,
first to clarify since some people before me might got it wrong already,
or I got it wrong.

If you talk about legend you are talking about a plot legend like
red line --- parameter 1
green line === parameter 2
blue line xxx parameter 3
etc.

or do you mean the figure caption like

Fig 1. This is a very nice figure which shows a blue, green, red and
black line.

For the second one you should follow the description of Uwe Lueck and in
my opinion this is the only correct way. Figure captions are part of the
document. They need to be formatted in a uniform standardized way
according to the layout and formatting rules of the manuscript. This
could only be provided by the document processor (e.g., LaTeX), since
the graphic program (e.g.,Matlab) has no idea how it has to look in the
final manuscript.

As for the first one... it is rather vice versa.
Please do not try to add a graph legend by LaTeX. Unlike you really know
what you are doing this would look almost always "wrong" since the
legend does not "fit" to the graph (e.g., different fonts, colour, size,
markers, etc.)

I guess what you want is to use Matlab to create your figures but you
need to make sure that the figures you produce have already the correct
size. You should not use rescaling options neither in LaTeX nor by any
other program. You need to save your figure directly with the final size
you are intended to place in your manuscript.
Only this way guarantees that all fonts have the same size.
Thus, if you need a figure of 5 x 7.5 cm for your manuscript you have to
create and save the figure in Matlab to be 5 x 7.5 cm. If you use a
raster format (jpg, png) you might need to tell Matlab to use a
resolution high enough for the printing process (e.g. 300 dpi).

Often people use much bigger figure sizes to display the image on the
monitor and become disappointed after saving them into a smaller size
figure. Since the fonts are not scaled accordingly, legends and axis
will be messed up.

If you create your figures in Matlab according to this rules from start,
you can directly see how they would look like in the final manuscript.

I didn't use Matlab for long time thus, I can't remember the necessary
commands. Please refer to the book "Mastering Matlab from Duane
Hanselman and Bruce Littlefield" which contains many many background
information which are not covered within the standard Matlab courses.

More rules which at least I follow for graph design:

1. Prefer black and white with good distinguishable plot markers or line
styles. Colour prints are still rare and xerox your paper would make it
unreadable.
2. In general use the same font you are using in the LaTeX document.
However, I prefer a sans-serif type which help to avoid problems with
grid-lines, punctuation, etc.
3. Use graph mark-up carefully, line width, markers, text, arrows, grid,
axes, etc. should not try to make your results more "beautiful". The
results are the important part. Choice simplicity over complexity. If
you have two lines in your plot, you can separated them by making one
solid and one dotted. I often see "funny" graphs which use different
markers, colours and line styles all together.

Hope that helps a bit

Torsten


More information about the texhax mailing list