在现有图上添加一个点 [英] Add a single point at an existing plot
问题描述
我正在使用以下脚本来拟合图上的函数.在输出图中,我想在拟合曲线上添加一个带有礼节的单个值,假设点f(3.25).我已经读过,对于gnuplot来说,在图上添加一个点非常棘手,尤其是当该图是拟合函数图时.
I am using the following script to fit a function on a plot. In the output plot I would like to add a single value with etiquette on the fitting curve lets say the point f(3.25). I have read that for gnuplot is very tricky to add one single point on a plot particularly when this plot is a fitting function plot.
有人知道如何在现有地块上添加此单点吗?
Has someone has an idea how to add this single point on the existing plot?
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
推荐答案
设置点/点有几种可能性:
There are several possiblities to set a point/dot:
如果您有简单的点,例如圆形,圆形楔形或正方形,则可以使用set object
,该点必须在相应的plot
命令之前定义:
If you have simple points, like a circle, circle wedge or a square, you can use set object
, which must be define before the respective plot
command:
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
.
To add a label, you need to use set label
.
这可能很麻烦,但是它的优点是可以使用不同的线条和填充颜色,并且可以使用不同的坐标系(first
,graph
,screen
等).
This may be cumbersome, but has the advantage that you can use different line and fill colors, and you can use different coordinate systems (first
, graph
, screen
etc).
4.6.4的结果是:
The result with 4.6.4 is:
set label
命令具有point
选项,可用于在特定坐标处使用现有点类型来设置点:
The set label
command has a point
option, which can be used to set a point using the existing point types at a certain coordinate:
set label at xPos, yPos, zPos "" point pointtype 7 pointsize 2
3.用'+'绘制
最后一种可能性是使用特殊的文件名+
,该文件名将生成一组坐标,然后将其过滤并使用labels
绘图样式(或points
(如果不要求标签的话)进行绘图)>
3. plot with '+'
The last possibility is to use the special filename +
, which generates a set of coordinates, which are then filtered, and plotted using the labels
plotting style (or points
if no label is requested:
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
).
$0
, or equivalently column(0)
, is the coordinate index. In the using
statement only the first one is taken as valid, all other ones are skipped (using NaN
).
请注意,使用+
需要设置固定的xrange
.
Note, that using +
requires setting a fixed xrange
.
这具有优点(或缺点?):
This has the advantages (or disadvantages?):
- 您可以使用通常的
pointtype
. - 您只能将轴值用作坐标(如上述对象的
first
或second
). - 放置不同的点类型可能会变得更加困难.
- 更多地使用不同的边框和填充颜色.
- You can use the usual
pointtype
. - You can only use the axis values as coordinates (like
first
orsecond
for the objects above). - It may become more difficult to place different point types.
- It is more involved using different border and fill colors.
结果是:
这篇关于在现有图上添加一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!