gnuplot:在epslatex中减小轴数使轴标签在屏幕外消失 [英] gnuplot: making axes numbers smaller in epslatex makes my axes label disappear offscreen

查看:72
本文介绍了gnuplot:在epslatex中减小轴数使轴标签在屏幕外消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,以在一列中生成三个图(使用多图和设置边距).它们都共享一个x轴,因此只需要在底部图上进行标记,但是它们具有单独的y轴.

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.

我正在gnuplot中使用epslatex终端生成带有乳胶标签和轴的图.基本上,我需要轴上的数字使用比实际轴标签小的字体大小.到目前为止,我一直在使用

I'm using the epslatex terminal in gnuplot to generate the plots with latex labels and axes. 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;

因此,如您所见,我使用乳胶将数字设置为不同的大小,特别是\ scriptsize.对于最后的xlabel,一切正常.数字以较小的字体显示,并且xlabel以常规尺寸打印在其下方.但是,对于ylabel,数字DO看起来较小,但实际标签名称未显示在图上.

So as you can see I use latex to format the numbers in a different size, specifically \scriptsize. For the xlabel at the end, everything works fine; the numbers are at a smaller font, and the xlabel prints just beneath it at the regular size. For the ylabels, however, the numbers DO appear smaller, but the actual label names don't appear on the plot.

起初,我虽然并没有以某种方式确认它们,但是当我尝试使用页边距时,我发现如果将lmargin移到页面中间,则ylabel会重新出现!看来,无论出于何种原因,它们都只是与轴本身相距很远.

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! 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.

推荐答案

出现这种现象的原因是gnuplot不知道,使用LaTeX语法的tic最终看起来将如何.该程序尝试估计tic标签长度,并相应地调整标签位置.

The reason for this behaviour is, that gnuplot doesn't know, how the tics with LaTeX syntax will ultimately look like. The program tries to estimate the tic label length and adjusts the label positions accordingly.

如果格式为'\scriptsize %g',则tic标签似乎很大:

If you have a format '\scriptsize %g', the tic labels seem to be very large:

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版本4.2.6根本没有考虑\scriptsize,您需要很大的偏移量来补偿它:set ylabel 'ylabel' offset 14.

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.

由于versoin 4.4的性能更好,因此您需要的偏移量要低得多:set ylabel 'ylabel' offset 4.

Since versoin 4.4 the behaviour is better, you need an much lower offset: set ylabel 'ylabel' offset 4.

一些评论:

  • \scriptsize是一个开关,不带参数.考虑set xlabel '\scriptsize{scriptsize} normal?'.要限制其效果,请用方括号括住文本,例如{\scriptsize %g}.但这并不是tic标签的必要条件,因为无论如何都将它们放在方括号中.

  • \scriptsize is a switch and doesn't take an argument. Consider set xlabel '\scriptsize{scriptsize} normal?'. To limit its effect, surround the text with brackets, like {\scriptsize %g}. But that is not necessary for tic labels, since they are in any case put in brackets.

要使用斜体文字,请使用\textit{label name 1},而不要使用带有$-符号的数学模式.

To have italic text, use \textit{label name 1}, and not the math mode with $-signs.

这篇关于gnuplot:在epslatex中减小轴数使轴标签在屏幕外消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆