0
votes

I need to visualize the accelerometer data as that given in the data sample below. The problem is with plotting them. I want to plot time on the X axis and data on the Y axis. I wanted to use set logscale y but it gives me the following error

all points y value undefined!

I know log(0) is not defined, so how should I plot them and not have only direct line?

Data sample:

0|22:47:34:217|-0.0047238474|0.0045838584|0.98415303
1|22:47:34:262|-0.00637105|0.010124308|0.98600864
2|22:47:34:312|-0.009391699|0.003311515|0.9806735
3|22:47:34:413|-0.008783525|-0.0034095072|0.9833411
4|22:47:34:462|-0.0053864615|0.0046849614|0.97668225
5|22:47:34:514|-0.009480359|0.0068983412|0.97258836
6|22:47:34:614|-0.010723149|0.0060241884|0.9775938
7|22:47:34:665|-0.013596032|0.0063897152|0.9779593
8|22:47:34:715|-0.013596032|0.006778573|0.9858702
9|22:47:34:815|-0.012471455|0.0017731927|0.98302996
1
Can you please tell us which column you want to plot against time? Obviously you can only plot the last one using a logarithmic scale, since the other ones have negative values. - Miguel
all of them :/ so how should I plot others ? any ideas ? - Mirko
I guess you should know how you must visualize your data. What do other people in your field do? - Christoph
I need to recognize steps so direct line is not what I need . Can I force Y-axis to look like I am using logscale ? - Mirko

1 Answers

0
votes

You can also plot the one before the last as it has only one negative value.

However, it simply is not possible to plot values <=0 on a log scale. So, you may just plot the absolute value, but then you loose the sign information. Or you can split it like this, plotting positive and (the absolute value of) negative values as different curves within the same plot:

plot "data" using 2:($4>0?$4:NaN) title "positive",\
     "data" using 2:($4<0?-$4:NaN) title "negative"

An alternative is not to use a log scale, but something similar that can handle negative values. E.g. the cubic root also accentuates small values and can be defined for negative values. Gnuplot can not do that for you, so you have to do the conversion on your own an plot on a linear scale:

cbrt(x) = sgn(x) * abs(x)**(1.0/3.0)
plot "data" using 2:(cbrt($4)) 

Unfortunately, the axis now does not show the actual values any more. There are tricks like putting your own tick marks at the right positions or (I think starting with version 5) linking left and right axis via a formula.

However, the small values of columns 2 and 3 are now in the range of (-)0.2, while column 4 remains at about 1. A higher amplification can be achieved by an odd root of higher degree.