在 x 轴上绘制含有太多零的数据

发布于 2025-01-12 21:56:49 字数 622 浏览 2 评论 0原文

我有这个 data1.dat 数据,我将使用 gnuplot 绘制它。

x        y
0.007   3.09216
0.008   3.60607
0.009   5.86643

然后我尝试用这个绘图脚本绘制它

set terminal svg size 400,300 enhanced fname 'arial'  
set output 'out2.png'

set xlabel 'diameter'
set ylabel 'number density'
set title 'density number plot'
plot  "data1.dat" using 3:4 title "" with lines

,x 轴的输出是这样的 输入图片此处描述

如何转换 x 轴上的数字数据,使其仅显示 7 或 8 的示例?这是一个例子,可能我的数据会变得更大,所以我无法在x列中一一更改data1.dat上的数据,提前致谢

I have this data1.dat data that I'd plot using gnuplot.

x        y
0.007   3.09216
0.008   3.60607
0.009   5.86643

then I tried to plot this with this plot script

set terminal svg size 400,300 enhanced fname 'arial'  
set output 'out2.png'

set xlabel 'diameter'
set ylabel 'number density'
set title 'density number plot'
plot  "data1.dat" using 3:4 title "" with lines

and the output in the x axis was like this
enter image description here

how to convert the number data on the x axis so it only shows only for example 7 or 8 only? this is an example and probably my data would getting bigger, so i can't change the data on data1.dat one by one in the x column, thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夢归不見 2025-01-19 21:56:49

显然,gnuplot 的 tic 算法没有考虑 ticlabel 的长度。这就是数字重叠的原因。
您可以执行以下操作:

  • 手动设置 xtic 增量以避免重叠,例如set xtic 0.0005

  • 将您的值乘以一个系数,例如 1000,特别是如果您有可以显示毫米的米,即 ($1* 1000)(column(1)*1000) 相同。

代码:

### avoid overlap of tic labels
reset session

$Data <<EOD
x        y
0.007   3.09216
0.008   3.60607
0.009   5.86643
EOD

set ytics 1
set multiplot layout 3,1

    set xlabel 'diameter / m'
    plot  $Data using 1:2 w l notitle

    set xlabel 'diameter / m'
    set xtic 0.0005
    plot  $Data using 1:2 w l notitle

    set xlabel 'diameter / mm'
    set xtics 0.2
    plot  $Data using ($1*1000):2 w l notitle

unset multiplot
### end of code

结果:

在此处输入图像描述

Apparently, gnuplot's tic algorithm doesn't take the length of the ticlabels into account. That's why the numbers are overlapping.
You can do the following:

  • set the xtic increment manually to avoid overlap, e.g. set xtic 0.0005

  • multiply your values by a factor, e.g. 1000, especially if you have meters you can display millimeters, i.e. ($1*1000) which is identical to (column(1)*1000).

Code:

### avoid overlap of tic labels
reset session

$Data <<EOD
x        y
0.007   3.09216
0.008   3.60607
0.009   5.86643
EOD

set ytics 1
set multiplot layout 3,1

    set xlabel 'diameter / m'
    plot  $Data using 1:2 w l notitle

    set xlabel 'diameter / m'
    set xtic 0.0005
    plot  $Data using 1:2 w l notitle

    set xlabel 'diameter / mm'
    set xtics 0.2
    plot  $Data using ($1*1000):2 w l notitle

unset multiplot
### end of code

Result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文