【问题标题】:How to remove trailing zeros from gnuplot y tics in gnuplot?如何从gnuplot中的gnuplot y tic中删除尾随零?
【发布时间】:2019-03-11 14:33:29
【问题描述】:

我想在 y 轴上应用对数刻度,抽动 1010.10.010.0010.00010.00001(不带尾随零)。您能帮我如何将这种格式提供给我的 GNUplot 脚本吗?

【问题讨论】:

    标签: gnuplot axis-labels


    【解决方案1】:

    使用xticsytics 等格式,您可以添加或替换轴上的任何刻度标签。

    set logscale y
    set format y '%g'
    set ytics add ('.00001' 0.00001, '.0001' 0.0001, '.001' 0.001, '.01' 0.01, '.1' 0.1)
    

    【讨论】:

      【解决方案2】:

      除了@Michael O. 的解决方案之外的另一种解决方案:

      ### custom tics
      reset session
      
      set logscale y
      set ytics nomirror
      do for [n in "-10 -9 -8 -7 -6 -5 -4 -3 -2 -1"] {
          set ytics add (".0000000000"[1:abs(n)]."1" 10**n)
      }
      
      set logscale y2
      set format y2 "10^{%T}"
      set y2tics 10 nomirror
      
      set xrange[-10:3]
      plot 10**x axis x1y1, 10**x axis x1y2
      ### end of code
      

      顺便说一句,如果你想去掉前导零只是因为节省空间,10^{%T} 格式会更节省空间(见右轴)。

      【讨论】:

        猜你喜欢
        • 2012-07-01
        • 2012-07-02
        • 1970-01-01
        • 2021-10-22
        • 2015-06-16
        • 2021-03-29
        • 2020-01-25
        • 2013-07-20
        • 2022-01-07
        相关资源
        最近更新 更多