开发者

Arranging non uniform xtics to a uniform scale in GNUPlot

开发者 https://www.devze.com 2023-03-12 15:55 出处:网络
I have a data set that uses the x-scale: 0.1 0.4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 But I need the tics to line up evenly, not have 0.1 and 0.4 scrunched up into the corner. I curr

I have a data set that uses the x-scale:

0.1 0.4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

But I need the tics to line up evenly, not have 0.1 and 0.4 scrunched up into the corner. I currently use,

set xtics 1
set xtics add (0.1)(0.4)

But that spaces 0.1 and 0.4 respective to the rest of the scale. I've attached a link to a tinypic I uploaded of my dummy data set with my current problem.

开发者_运维知识库http://tinypic.com/r/2zfolxf/7


Current State

As far as I know, you can do the following in gnuplot with tics (at least what is relevant to your question):

  • You can specify the start, increment and end of the tics displayed.
    This would make sense to you, if you wish to simply set the tics after the value of 2 like

    set xtics 2, 1
    
  • The other thing you can do, is add explicit tic labels to certain values like

    set xtics add ("0.1" 0, "0.4" 1)
    

    This would introduce the labels 0.1, and 0.4 to the x scale where the actual values are 0 and 1

However you cannot modify the actual plotting of the graph. If in you data it states

0.1 100
0.4 150
1   200
2   300

then gunplot will plot it correspondingly.

Possible workaround

A workaround could look like this:

  1. Plot the normal graph from 2 upwards.
  2. Do some hackery stuff to the first two values with this:

    plot "Data.dat" every 1::2 w l, "" every 1::1::2 using ($1<magic>):($2)
    

magic specifies some algebraic operation you want to do with the first column.
Everything is allowed and if your values are constant you can specify a polynomial that goes through the points 0, 1 and 2 with the inputs 0.1, 0.4 and 1 like this polynomial:

y = -1.85*x^2 + 4.26*x - 1.4

Example

Suppose you have this data file:

0.1 0.41
0.4  0.03
1 0.97
2  0.74
3  0.05
4  0.15
5   0.11 
6 0.60
7 0.76
8 0.25 

Then you can "rearrange" the first two entries to the x-positions -1 and 0 like this:

plot "Data.dat" every 1::2 w l, \
"" every 1::0::2 using (-1.85*$1**2 + 4.26*$1 - 1.4):($2) w l

With some tic-labeling and line style settings it should look exactly like what you are after.

I hope I understood what you are after and that you can make some use of my suggestions.
Cherio
Woltan

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号