dkogan/feedgnuplot

How can I use variables with feedgnuplot?

097115 opened this issue · 7 comments

I can probably assign a var with --cmds 'var="TEST"'. But can I use it later? For instance, when setting a title?

(The problem that I actually have in mind is a bit more complex: I have a stream with three columns, the first two are coordinates for axes, and the third one is a constant that I'd like to use as a frequency setting for xtics. Would it be possible?)

Thank you for your reply!

OK, let's say this is my sample data:

1675612343  3088.00 10
1675612346  3088.79 10
1675612353  3087.85 10
1675612358  3086.00 10
1675612359  3079.00 10
1675612364  3080.82 10
1675612371  3079.00 10
1675612371  3078.00 10
1675612374  3080.00 10
1675612383  3083.00 10
1675612394  3081.74 10
1675612395  3088.01 10
1675612404  3076.37 10

And this would be my script (which produces this plot):

feedgnuplot \
    --domain \
    --timefmt '%s' \
    --terminal "wxt" \
    --set "xtics 10 rotate by 90 right tc rgb '#386cb0' scale 0.01" \
    --set 'ytics tc rgb "#386cb0" scale 0.01' \
    --lines --set "format x \"%H:%M:%S\"" \
    --rangesize 1 2

As you can see, the third column in the data is 10. And my xtics setting contains this frequency, 10, which is set manually.

Now, I wonder, can I somehow make feedgnuplot to use that constant from the third column as a frequency parameter for xtics?

Of course, if the data would be in a file, then we could use some shell command to obtain that number. But what if the data is just piped into feedgnuplot? (and we'd prefer not to create any temp files :)

If you're assuming that the 3rd column always has the same value

Yeah :)

My data is generated by extracting it from some large dataset with awk, and the 3 column is calculated once and for all by awk based on the first and the last entries from that dataset, so it's indeed a constant. However, the datasets do differ, and sometimes entries lie within a few minitues, thus 10 seconds is enough, and sometimes lasts over hours, and to keep xtics readable, a larger number is required. But again, it's handled by the awk script which prepares the data for gnuplot.

(Now that I'm writing it, I got thinking that may be it's somehow possible simply to limit the plot to some fixed number of xtics, like always print exactly 30 xtics, no matter what is the data is -- and therefore let gnuplot to calculate the autofreq itself... But after some googling, it seems gnuplot doesn't offer such option, right?)

As of now, I work around by creating a temp file with the awk prepared data, extracting the third column to some var, and then feeding that file and that var to feedgnuplot. It works OK, I just don't really like creating / managing / deleting temp files :)

So I thought may combining everything into a single pipe < large_dataset awk '{extracting_some_values}' | feedgnuplot --some-commands could work. But judging by your comment I see that it's not really doable, am I right?

magic comment in a header

Is this just a phrase, or indeed some technique? Sounds like may be it could help? :)

(Once again, thank you for your time. As I see it now, my quesion isn't really related to feedgnuplot, so I do appreciate your help.)

you should look at the vnlog project: github.com/dkogan/vnlog/ . It works very nicely with
feedgnuplot.

I watched your presentation some time ago :)

It's doable. For instance:

Oh, that's interesting, thanks for a hint :)

You can have a datafile like this:

## xtic_frequency: 6.1
1675612343  3088.00
1675612346  3088.79
1675612353  3087.85

And whatever needs it can parse that out.

But not gnuplot or freegnuplot, right?

(I'm probably closing this, but again, thank you for your interest, and have a nice day!)