October 24th, 2013 |
If you want to put labels into a graph using the epslatex terminal you are probably interested in using a smaller font for these labes than for the rest of the figure. An example is presented in Fig. 1.
Figure 1 shows again the photon flux density from one of the last posts, but this time plotted with the
epslatex terminal. The label size is changed by setting it to
\footnotesize with the following code. First we introduce a abbreviation for the font size by adding a command definition to the header of our latex file.
set terminal epslatex size 9cm,7cm color colortext standalone header \
After the definition of the abbreviation we can use it for every label we are interested in.
set label 2 '\ft $5$\,meV' at 1.38,4e9 rotate by 78.5 center tc ls 1
set label 3 '\ft $10$\,meV' at 1.24,2e10 rotate by 71.8 center tc ls 2
set label 4 '\ft $20$\,meV' at 1.01,9e11 rotate by 58.0 center tc ls 3
set label 5 '\ft $40$\,meV' at 0.81,1e15 rotate by 43.0 center tc ls 4
set label 6 '\ft $60$\,meV' at 0.76,9e16 rotate by 33.0 center tc ls 5
set label 7 '\ft $80$\,meV' at 0.74,2.5e18 rotate by 22.0 center tc ls 6
set label 8 '\ft $E_0 = 100$\,meV' at 1.46,5e18 rotate by -40.5 center tc ls 7
Tags: data, epslatex, label, legend, logscale, standalone
July 30th, 2013 |
If you have more than one line or data set in your figure, they has to be named somehow. I’m not a big fan of a legend but prefer to put the names directly to the corresponding curves. That makes it easier for the reader. But as an author of the figure you have to find space to place the labels in the figure, and it could be that you have to rotate the labels to stick them to the lines.
Figure 1 shows the theoretical curves of photon flux density dependent on the photon energy for different characteristic tail state energies E0. E0 is an indicator for disorder in a crystalline system. To reduce the amount of trail and error for placing the E0 labels, we get the rotation directly from the data by fitting a linear function to the corresponding part of the data.
It is a little bit tricky, because we have a logarithmic y-axis. This can be handled by applying the logarithm to the y data by
log($2) and than do the linear fiting.
f(x) = a*x+b
fit [1.30:1.34] [*:*] f(x) 'PL_spectrum_mu_1.0eV_E0_05meV_300K.dat' \
u 1:(log($2)) via a,b
The first bracket is the range on the x-axis and the second sets the corresponding y range to auto. After we have the value of the slope we convert it to a rotation in degree with the
r() function and set our label.
set label 2 '5 meV' at 1.38,4e9 rotate by r(a) center tc ls 1
The conversion to rotation is the most tricky part, because it depends on the range of your axes and the ratio between them. it would be trivial if both axes would go from, for example 1:10 and are equal in length in the figure. Otherwise we have to correct for the ranges and ratio.
# get the relation of x- and y-range
dx = xmax-xmin
dy = log(ymax)-log(ymin)
s1 = dx/dy
# get ratio of axes
s2 = 5/6.7
# helper function for getting the rotation angle of the labels in degree
deg(x) = x/pi*180.0
r(x) = deg(atan(s1*s2*x))
Tags: data, fit, label, legend, logscale