zoukankan      html  css  js  c++  java
  • gnuplotx轴的logscale显示

    假设数据是这样子的:

    2    10
    4    20
    8    30
    16    40
    32    50
    64    60
    128    70
    256    80
    512    90
    1024    100

    gnuplot脚本如下:

     1 set terminal postscript eps color enhanced
     2 set log x 2
     3 set log y 10
     4 set format x '2^{%L}'
     5 set yrange[10:120]
     6 set ytics(10,50,100,120)
     7 set format y '%2.1t*10^{%L}'
     8 set output 'test.eps'
     9 set ylabel 'value' offset 2.0
    10 set xlabel 'param' offset 0, 0
    11 plot 'test.txt' using 1:2 with lp lw 4 ps 1.9 lt 1 pt 4 lc rgb 'red' title 'test'; 
    12 set output

    using 1:2 就是将第一列作为x轴,第二列作为y轴。注意,如果用using 2:xticlabels(1) 的话,只是将第一列当作label(文本类型),再设置它的logscale就会出问题。

    现在要把第一列以logscale (base 2)显示,也就是最终是以幂的形式,并且等距显示,使用:

    set log x 2 将x轴设成base 2的logscale。

    set format x '2^{%L}' 指定x轴的显示方式。^需要enhanced text mode,因此需要

    set terminal postscript eps color enhanced

    正常来说,如果以base 10的log scale显示的话,是会以1,10,100...的刻度显示的,但是有时候我们希望是1*10-1,1.5*10-1这种显示。这时可以这么做:

    1 set yrange[10:120]
    2 set ytics(10,50,100,120)
    3 set format y '%2.1t*10^{%L}'

    注意顺序,先设range,再设tics,再设format。

    最终结果如下:

  • 相关阅读:
    烯烃(olefin) 题解
    二分图的考验 题解
    树上的好题
    [SDOI2013]直径 题解
    [ZJOI2010]数字计数 题解
    神在夏至祭降下了神谕 题解
    洛谷 P4198 楼房重建 题解
    [HAOI2010]软件安装 题解
    [POI2011]ROT-Tree Rotations 题解
    可并堆之左偏树浅谈
  • 原文地址:https://www.cnblogs.com/linyx/p/3685448.html
Copyright © 2011-2022 走看看