简体   繁体   English

gnuplot:在epslatex中减小轴数使轴标签在屏幕外消失

[英]gnuplot: making axes numbers smaller in epslatex makes my axes label disappear offscreen

I'm writing a script to generate three plots in a column (using multiplot and setting margins). 我正在编写一个脚本,以在一列中生成三个图(使用多图和设置边距)。 They all share an x-axis, so it's only necessary to label that on the bottom plot, but they have separate y-axes. 它们都共享一个x轴,因此只需要在底部图上进行标记,但是它们具有单独的y轴。

I'm using the epslatex terminal in gnuplot to generate the plots with latex labels and axes. 我在gnuplot中使用epslatex终端生成带有乳胶标签和轴的图。 Basically, I need the numbers on the axis to use a smaller font size than the actual axis labels. 基本上,我需要轴上的数字使用比实际轴标签小的字体大小。 So far, I've been doing this using, 到目前为止,我一直在使用

reset

set term epslatex standalone color solid 10
set output 'myplot.tex'

set multiplot;

    #Common width for all three plots is set

    set lmargin at screen 0.15;
    set rmargin at screen 0.90;

    set format x ""; #Removes xlabels from plots without removing tic marks

    #First plot

    set tmargin at screen 0.98;
    set bmargin at screen 0.72;

            set ylabel '$Label Name 1$';
            set format y '\scriptsize{%g}';
            plot "mydata.dat" u 1:3 w l lt 1 lw 3

    #Second plot

    set tmargin at screen 0.70;
    set bmargin at screen 0.44;
            set ylabel '$Label Name 2$';
            set format y '\scriptsize{%g}';
            plot "mydata.dat" u 1:11 w l lt 2 lw 3

    #Third plot

    set tmargin at screen 0.42;
    set bmargin at screen 0.16;
            set xlabel 'Common Label Name'; 
            set format x '\scriptsize{%g}'; # Here I reset the x axis so it shows on 
                                              this plot
            set ylabel 'Label Name 3';
            set format y '\scriptsize{%g}';
            plot "mydata.dat" u 1:5 w l lt 3 lw 3

unset multiplot;

So as you can see I use latex to format the numbers in a different size, specifically \\scriptsize. 如您所见,我使用乳胶将数字设置为不同的大小,特别是\\ scriptsize。 For the xlabel at the end, everything works fine; 对于最后的xlabel,一切正常。 the numbers are at a smaller font, and the xlabel prints just beneath it at the regular size. 数字以较小的字体显示,并且xlabel以常规尺寸打印在其下方。 For the ylabels, however, the numbers DO appear smaller, but the actual label names don't appear on the plot. 但是,对于ylabel,数字DO看起来较小,但实际标签名称未显示在绘图上。

At first I though they weren't being acknowledged somehow, but when I experimented with the margins, I found that if I move lmargin to the middle of the page, the ylabels reappear! 最初我虽然并没有以某种方式得到承认,但是当我尝试使用页边距时,我发现如果将lmargin移到页面中间,则ylabel会重新出现! It seems, for whatever reason, they're just being drawn some large distance from the axes themselves. 看起来,无论出于何种原因,它们都只是与轴本身相距很远。

I've tried setting the labels with an offset, but that yields no joy. 我试过设置带有偏移量的标签,但这并没有带来喜悦。

The reason for this behaviour is, that gnuplot doesn't know, how the tics with LaTeX syntax will ultimately look like. 出现这种现象的原因是gnuplot不知道,使用LaTeX语法的tic最终看起来将如何。 The program tries to estimate the tic label length and adjusts the label positions accordingly. 程序尝试估计tic标签长度,并相应地调整标签位置。

If you have a format '\\scriptsize %g' , the tic labels seem to be very large: 如果格式为'\\scriptsize %g' ,则tic标签似乎很大:

set terminal epslatex standalone 
set output 'label-offset.tex'
set format y '\scriptsize %g'
set ylabel 'ylabel'
plot x

set output
system('latex label-offset.tex && dvips label-offset.dvi && ps2pdf label-offset.ps')

Gnuplot version 4.2.6 doesn't consider the \\scriptsize at all and you need a very large offset to compensate it: set ylabel 'ylabel' offset 14 . Gnuplot版本4.2.6根本不考虑\\scriptsize ,您需要很大的偏移量来补偿它: set ylabel 'ylabel' offset 14

Since versoin 4.4 the behaviour is better, you need an much lower offset: set ylabel 'ylabel' offset 4 . 由于versoin 4.4的行为更好,因此您需要一个低得多的偏移量: set ylabel 'ylabel' offset 4

Some remarks: 一些说明:

  • \\scriptsize is a switch and doesn't take an argument. \\scriptsize是一个开关,不带参数。 Consider set xlabel '\\scriptsize{scriptsize} normal?' 考虑set xlabel '\\scriptsize{scriptsize} normal?' . To limit its effect, surround the text with brackets, like {\\scriptsize %g} . 为了限制其效果,请在文本周围加上方括号,例如{\\scriptsize %g} But that is not necessary for tic labels, since they are in any case put in brackets. 但这并不是tic标签的必要条件,因为它们总是放在括号中。

  • To have italic text, use \\textit{label name 1} , and not the math mode with $ -signs. 要使用斜体文字,请使用\\textit{label name 1} ,而不要使用带有$符号的数学模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM