gnuplot - 在现有绘图上添加一个点

标签 gnuplot

我正在使用以下脚本来拟合绘图上的函数。在输出图中,我想在拟合曲线上添加一个带有礼节的单个值,可以说点 f(3.25)。我读过,对于 gnuplot,在图上添加一个点非常棘手,尤其是当该图是拟合函数图时。

有人知道如何在现有图上添加这个单点吗?

set xlabel "1000/T (K^-^1)" font "Helvetica,20"    
#set ylabel "-log(tau_c)"       font "Helvetica,20"    
set ylabel "-log{/Symbol t}_c (ns)"     font "Helvetica,20"    
set title  "$system $type $method"        font "Helvetica,24"    
set xtics      font "Helvetica Bold, 18"                                  
set ytics      font "Helvetica Bold, 18"                                  
#set xrange[0:4]
set border linewidth 3
set xtic auto                          # set xtics automatically
set ytic auto                          # set ytics automatically
#set key on bottom  box lw 3 width 8 height .5 spacing 4 font "Helvetica, 24"
set key  box lw 3 width 4 height .5 spacing 4 font "Helvetica, 24"

set yrange[-5:]
set xrange[1.5:8]
f(x)=A+B*x/(1000-C*x)

A=1 ;B=-227 ; C=245

fit  f(x) "$plot1" u (1000/\$1):(-log10(\$2)) via A,B,C

plot [1.5:8] f(x)  ti "VFT" lw 4,  "$plot1" u (1000/\$1):(-log10(\$2)) ti "$system $type" lw 10



#set key on bottom  box lw 3 width 8 height .5 spacing 4 font "Helvetica, 24"

set terminal postscript eps color dl 2 lw 1 enhanced # font "Helvetica,20"

set output "KWW.eps"                                              



replot

最佳答案

设置点/点有多种可能性:

1.设置对象

如果您有简单的点,例如圆、圆楔形或正方形,您可以使用 set object ,必须在各自的 plot 之前定义命令:

set object circle at first -5,5 radius char 0.5 \
    fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at graph 0.5,0.9 radius char 1 arc [0:-90] \
    fillcolor rgb 'red' fillstyle solid noborder
set object rectangle at screen 0.6, 0.2 size char 1, char 0.6 \
    fillcolor rgb 'blue' fillstyle solid border lt 2 lw 2

plot x

要添加标签,您需要使用 set label .

这可能很麻烦,但优点是您可以使用不同的线条和填充颜色,并且可以使用不同的坐标系( firstgraphscreen 等)。

4.6.4 的结果是:

enter image description here

2.设置一个带点选项的空标签
set label命令有一个 point选项,可用于使用特定坐标处的现有点类型设置点:
set label at xPos, yPos, zPos "" point pointtype 7 pointsize 2

3. 用'+'绘图

最后一种可能性是使用特殊文件名 + ,生成一组坐标,然后过滤,并使用 labels 绘制。绘图样式(或 points 如果没有要求标签:
f(x) = x**2
x1 = 2

set xrange[-5:5]
set style line 1 pointtype 7 linecolor rgb '#22aa22' pointsize 2
plot f(x), \
     '+' using ($0 == 0 ? x1 : NaN):(f(x1)):(sprintf('f(%.1f)', x1)) \
     with labels offset char 1,-0.2 left textcolor rgb 'blue' \
     point linestyle 1 notitle
$0 ,或等效地 column(0) , 是坐标索引。在 using语句只有第一个被认为是有效的,所有其他的都被跳过(使用 NaN )。

请注意,使用 +需要设置一个固定的 xrange .

这有优点(或缺点?):
  • 您可以使用通常的 pointtype .
  • 您只能将轴值用作坐标(如上述对象的 firstsecond)。
  • 放置不同的点类型可能会变得更加困难。
  • 它更涉及使用不同的边框和填充颜色。

  • 结果是:

    enter image description here

    关于gnuplot - 在现有绘图上添加一个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19452516/

    相关文章:

    colors - gnuplot:如何创建彩色网格区域,而不仅仅是彩色网格线?

    带有来自 3D 数据集的热图的 gnuplot 2D 极坐标图 - 可能吗?

    command-line - 在 Windows 上使用 Gnuplot 控制 ImageMagick 的 '-FX' 函数的曲线公式

    gnuplot 5 多图对齐不向后兼容

    Gnuplot 键水平间距

    math - 如何使用 GNUplot 获得更好的指数拟合?

    c++ - Gnuplot 持久图形窗口

    perl - 我可以在 Chart::Gnuplot (Perl) 中填充绘图吗?

    c++ - 找不到用 C++ 编写的 gnuplot.exe 路径

    fortran - 使用 Fortran 90 在 Gnuplot 中进行条件绘图