English 中文(简体)
我如何在eps和pdf终端在gnuplot的输出上实现一致性?
原标题:How do I achieve consistency in output in eps and pdf terminals in gnuplot?
  • 时间:2012-05-23 21:40:13
  •  标签:
  • gnuplot

我试图在 gnuplot 中取得 eps 和 pdf 终端之间某种一致的输出。 问题在于它们似乎对大小单位的理解不同; 相同的英寸指定大小将导致 pdf 输出的字体大小大得多 :

set terminal postscript eps enhanced colour size 10in,8in font  Arial-Bold,14 
set output  my_eps.eps 
set title  My plot 
plot sin(x) notitle

set terminal pdfcairo size 10in,8in font  Arial-Bold,14 
set output  my_pdf.pdf 
replot

.pdf 中的文字要大得多, 图形也缩窄。 但是, 如果我将eps 的大小单位修改为 cm :

set terminal postscript eps enhanced colour size 10cm,8cm font  Arial-Bold,14 
                                                 ########
set output  my_eps.eps 
set title  My plot 
plot sin(x) notitle

set terminal pdfcairo size 10in,8in font  Arial-Bold,14 
set output  my_pdf.pdf 
replot

输出与错误单位看起来相同( 在某些差值错误之内 ) 。 这是巧合吗? 这里发生了什么?

测试结果为Gnuplot 4.4(3级) Ubuntu 11.10。

(我知道我可以使用一些工具在eps和pdf之间转换, 这样它们就会相同, 但我想了解在gnuplot中发生了什么。)

问题回答

在同一单元系统中有两块地块,预计这种行为会发生 -- -- 虽然也许没有很好/准确的记录。 (来自help post )

In `eps` mode the whole plot, including the fonts, is reduced to half of 
the default size.

既然您明确指定了一个大小, 这部分棒, 但字体在 eps 绘图上的大小仍然减少2倍, 即使您明确指定了字体( 我不知道这是为什么, 但总是这样 -- 我一向认为它在文档中至少... ) 。

至于将单位切换到厘米值-- 我不在计算机上安装了 cairo 终端, 所以我现在不能检查... 但看起来很奇怪(对我来说) 。 也许是因为英寸的转换到厘米值大约是二分之一左右, 这使得它们看起来如此相似吗? (例如, 您的字体是一半大小, 而您的绘图是1.5.54大小) 。

为了实现终端独立,我想你可以把它写成一个函数( " 坚固 > 直截了当 < /坚固 > ):

fontsize(x)=((GPVAL_TERM eq  postscript ) && 
             (strstrt(GPVAL_TERMOPTIONS,"eps")!=0)) ? x*2 : x
set term post eps enh size 10in,8in
set termoption font "Arial,".fontsize(7)
set output "Hello.eps"
plot sin(x)

set term pdfcairo enh size 10in,8in
set termoption font "Arial,".fontsize(7)
set output "Hello.pdf"
plot sin(x)

确保您只将整数传递到字体大小 -- -- 当进行字符串连接时, 整数会被提升到字符串 。

<强 > EDIT

在进一步挖掘之后, Cairo 图书馆似乎有些自由, 并嵌入一个您没有要求的(类似)字体。

运行 pdffonts my file.pdf - 请注意,您只要通过 strings my file.pdf\\\ grep fontName 就可以得到字体名 :

name                 type         emb sub uni object ID
-------------------- ------------ --- --- --- ------ --
LiberationSansBold   CID TrueType yes no  yes      5 0

上标仅包含由 ps 查看器翻译为最接近所请求字体的字体名称( 不是嵌入的) 。 因此, 要实现真正的终端独立( 在这两个终端之间), 您需要找到嵌入 pdf 的字体文件, 然后 设定 epps enh 彩色字体文件, 添加“ & lt; fontfile>” 以在 pdf 和 postrip 中嵌入相同的字体文件 。

Achieve 100% consistency with Ghostscript

我使用 < a href=> "http://ghostscript.com/" rel="nofollow" >Ghostscript 将 gnuplot 创建的封套邮电表Script (EPS) 图形转换为 PDF。 有用!

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.eps




相关问题
Choosing line type and color in Gnuplot 4.0

I have two pairs of datasets, which I need to plot using Gnuplot. I want the first pair to be plotted in red, one solid and one dashed. The second pair, I want to plot in blue, one solid and one ...

Graph Formatting Tools For Octave

I know that Matlab allows for you to format the graph after its created through the interface. However there isn t the same features in Octave. Is there a tool that goes between Octave and GnuPlot? If ...

Labels on the input data in gnuplot

I have a datafile that looks like this #index name1 name2 name3 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 I want to plot 3 lines: plot "data" using 1:2 with lines, ... This works ok, except for the line ...

Drawing gant-like diagram from file in C with boxes and axis

I am programming system in C and I would like to draw rectangles into 2D plain with axis X and Y to represent generated data (scheduling problems).It should LOOK LIKE gant chart. Information are ...

Treat axis as date/time (epoch)

I m generating a graph with gnuplot of activity over the last twenty four hours, but the time axis looks really bad because it s trying to fit the long number for every five minutes in the last day. ...

Gnuplot Cumulative Column Question

I have some data. #Time Distance 1 3 2 5 4 9 8 11 12 17 14 20 16 34 20 40 I want to plot the cumulative distance wrt time in gnuplot ... (it should be easy) but I do not know how. x

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...