在 Gnuplot 中以不同间距绘制 y 轴标签

发布于 2024-10-09 13:20:12 字数 131 浏览 0 评论 0原文

我正在尝试使用 gnuplot 创建条形图。我的要求是我应该能够将 y 轴标记为 0、1、100、10,000(即每个刻度增加 100 倍,1 和 0 之间除外)。另外,这不是对数刻度,因为我希望它从 0 开始。如果您知道如何执行此操作,请告诉我。

I am trying to create a barchart using gnuplot. My requirement is that I should be able to label y-axis as 0, 1, 100, 10,000 (i.e., each tick increases by a factor of 100, except between 1 and 0). Also, this is not log-scale as I want this to start at 0. Let me know if you know how to do this.

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

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

发布评论

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

评论(2

一个人练习一个人 2024-10-16 13:20:12

您可以使用 set xtics:

gnuplot> set xtics ("0" 1, "1" 2, "100" 3, "10000" 4)
gnuplot> plot "test.dat" notitle with boxes

生成以下图:

http:// marco.uctleg.net/resources/sample_xtics.png

包含以下数据:

1 12
2 8
3 19
4 42

编辑:刚刚注意到您要求更改 y 轴。基本上是一样的,我相信你能解决。

You can use set xtics:

gnuplot> set xtics ("0" 1, "1" 2, "100" 3, "10000" 4)
gnuplot> plot "test.dat" notitle with boxes

produces the following plot:

http://marco.uctleg.net/resources/sample_xtics.png

with the following data:

1 12
2 8
3 19
4 42

EDIT: Just noticed you asked to change the y-axis. It's much the same, I'm sure you can work it out.

记忆消瘦 2024-10-16 13:20:12

Marcog 的答案可能是获得您想要的结果的最佳方法,

但是,如果您不想重新分配 1 表示“0”,2 表示“1”等,
那么你可以尝试一个简单的

set ytics (0,1,100,10000)

方法将抽动设置在你想要的地方,
然后使用设置的格式 y 指定抽动的格式。

例如,

set format y "10^{%L}"

将 tics 以漂亮的指数形式放置(请注意,这种特定格式在 postscript 输出中看起来很漂亮,但在默认的 gnuplot 窗口中却相当丑陋)。

请参阅http://t16web.lanl.gov/Kawano/gnuplot/tics-e。有关设置格式命令的更多信息,请参见 html(页面中间)。

一切顺利

Marcog's answer is probably the best way to get exactly what you want,

However, if you don't want to do the reassignment of 1 means "0", 2 means "1" etc,
then you could try a simple

set ytics (0,1,100,10000)

To set the tics where you want them,
and then use the set format y to specify the format of the tics.

For example

set format y "10^{%L}"

to put the tics in nice exponential form (note this particular formatting looks pretty in postscript output, but rather ugly in the default gnuplot window).

See http://t16web.lanl.gov/Kawano/gnuplot/tics-e.html for more on the set format command (midway down the page).

All the best

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