Gnuplot - can “smooth frequency” work whole file (including multiple datablocks/indices)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Situation
Two metering devices (A, B) give data like
# meter A
time1 14.5
time2 9.3
time3 11.1
…
Thanks to some "binning" the timestamps from A and B might be identical (think of ice cream cones of different flavours sold per hour).
Aim
To get the total amount vs. time I'd like to use "smooth frequency", which should do what I want to achieve.
Already tried
Both "binned" datasets are "plotted" (set table $DB) into a internal here-document or temp-file on disk. But the datasets are separated by blank lines.
# meter A
time1 14.5
time2 9.3
time3 11.1
…
# meter B
time2 8.2
time3 2.8
...
Is it possible to use "smooth frequency" with the whole datafile to get something like
# meter A+B
time1 14.5
time2 17.5
time3 13.9
…
using only gnuplot? If so - how?
NB: The solution should work under windows, an installation of additional software is not possible. (Worst case: plot the combined data into a file and remove the blank lines in an editor...)
gnuplot
add a comment |
Situation
Two metering devices (A, B) give data like
# meter A
time1 14.5
time2 9.3
time3 11.1
…
Thanks to some "binning" the timestamps from A and B might be identical (think of ice cream cones of different flavours sold per hour).
Aim
To get the total amount vs. time I'd like to use "smooth frequency", which should do what I want to achieve.
Already tried
Both "binned" datasets are "plotted" (set table $DB) into a internal here-document or temp-file on disk. But the datasets are separated by blank lines.
# meter A
time1 14.5
time2 9.3
time3 11.1
…
# meter B
time2 8.2
time3 2.8
...
Is it possible to use "smooth frequency" with the whole datafile to get something like
# meter A+B
time1 14.5
time2 17.5
time3 13.9
…
using only gnuplot? If so - how?
NB: The solution should work under windows, an installation of additional software is not possible. (Worst case: plot the combined data into a file and remove the blank lines in an editor...)
gnuplot
add a comment |
Situation
Two metering devices (A, B) give data like
# meter A
time1 14.5
time2 9.3
time3 11.1
…
Thanks to some "binning" the timestamps from A and B might be identical (think of ice cream cones of different flavours sold per hour).
Aim
To get the total amount vs. time I'd like to use "smooth frequency", which should do what I want to achieve.
Already tried
Both "binned" datasets are "plotted" (set table $DB) into a internal here-document or temp-file on disk. But the datasets are separated by blank lines.
# meter A
time1 14.5
time2 9.3
time3 11.1
…
# meter B
time2 8.2
time3 2.8
...
Is it possible to use "smooth frequency" with the whole datafile to get something like
# meter A+B
time1 14.5
time2 17.5
time3 13.9
…
using only gnuplot? If so - how?
NB: The solution should work under windows, an installation of additional software is not possible. (Worst case: plot the combined data into a file and remove the blank lines in an editor...)
gnuplot
Situation
Two metering devices (A, B) give data like
# meter A
time1 14.5
time2 9.3
time3 11.1
…
Thanks to some "binning" the timestamps from A and B might be identical (think of ice cream cones of different flavours sold per hour).
Aim
To get the total amount vs. time I'd like to use "smooth frequency", which should do what I want to achieve.
Already tried
Both "binned" datasets are "plotted" (set table $DB) into a internal here-document or temp-file on disk. But the datasets are separated by blank lines.
# meter A
time1 14.5
time2 9.3
time3 11.1
…
# meter B
time2 8.2
time3 2.8
...
Is it possible to use "smooth frequency" with the whole datafile to get something like
# meter A+B
time1 14.5
time2 17.5
time3 13.9
…
using only gnuplot? If so - how?
NB: The solution should work under windows, an installation of additional software is not possible. (Worst case: plot the combined data into a file and remove the blank lines in an editor...)
gnuplot
gnuplot
asked Feb 9 at 18:00
rascalrascal
1112
1112
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I will try to answer my own question since right now my problem seems to be solved.
Data setup
File: "A.dat"
2.3 8.2
3 7
4.3 6.3
1 9
3.3 7.3
2 8
4 6
1.3 9.1
File: "B.dat"
1.1 1.1
3 3
3.1 3.3
2 2
1 1
4.1 4.4
2.1 2.1
4 4
My solution relies heavily on "in-memory-files" (here-docs), but I assume (not testet!) it works with temporary files on disk as well.
The following script may not be very sophisticated, but it's working:
set xrange [0:5]
set yrange [0:*]
# simple binnig function (good enough for this demo)
binwidth = 1.0
bin(x) = binwidth * floor(x/binwidth)
# transfer original data to in-memory-files
set table $A_orig
plot "A.dat" with table
unset table
set table $B_orig
plot "B.dat" with table
unset table
# binning into new in-memory-file
set table $A_bin
plot $A_orig using (bin($1)):2
unset table
set table $B_bin
plot $B_orig using (bin($1)):2
unset table
# using in memory-files
# unique-filter: x -> avg(y)
set table $A_uniq
plot $A_bin smooth unique
unset table
set table $B_uniq
plot $B_bin smooth unique
unset table
# unite the different 'uniqued' datasets
# important: use plotstyle "with table"!
set table $AB_unite
plot $A_uniq with table,
$B_uniq with table
unset table
# apply smooth frequency (x->sum(y))
set table $AB_tmp
plot $AB_unite smooth freq
unset table
# create final in-memory-file
set table $AB_freq
plot $AB_tmp with table
unset table
# plot all results
plot $A_orig with points pointsize 2 title "A (original)",
$B_orig with points title "B (original)",
$A_bin with points title "A (binned)",
$B_bin with points title "B (binned)",
$A_uniq with linespoints title "A (binned,unique)",
$B_uniq with linespoints title "B (binned,unique)",
$AB_freq with linespoints title "A+B (binned,unique,frequency)"
# clean
undef $A_*
undef $B_*
undef $AB_*
The important trick is not only to use "set table", but finding out when to use plotstyle "with table" as well.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1403930%2fgnuplot-can-smooth-frequency-work-whole-file-including-multiple-datablocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I will try to answer my own question since right now my problem seems to be solved.
Data setup
File: "A.dat"
2.3 8.2
3 7
4.3 6.3
1 9
3.3 7.3
2 8
4 6
1.3 9.1
File: "B.dat"
1.1 1.1
3 3
3.1 3.3
2 2
1 1
4.1 4.4
2.1 2.1
4 4
My solution relies heavily on "in-memory-files" (here-docs), but I assume (not testet!) it works with temporary files on disk as well.
The following script may not be very sophisticated, but it's working:
set xrange [0:5]
set yrange [0:*]
# simple binnig function (good enough for this demo)
binwidth = 1.0
bin(x) = binwidth * floor(x/binwidth)
# transfer original data to in-memory-files
set table $A_orig
plot "A.dat" with table
unset table
set table $B_orig
plot "B.dat" with table
unset table
# binning into new in-memory-file
set table $A_bin
plot $A_orig using (bin($1)):2
unset table
set table $B_bin
plot $B_orig using (bin($1)):2
unset table
# using in memory-files
# unique-filter: x -> avg(y)
set table $A_uniq
plot $A_bin smooth unique
unset table
set table $B_uniq
plot $B_bin smooth unique
unset table
# unite the different 'uniqued' datasets
# important: use plotstyle "with table"!
set table $AB_unite
plot $A_uniq with table,
$B_uniq with table
unset table
# apply smooth frequency (x->sum(y))
set table $AB_tmp
plot $AB_unite smooth freq
unset table
# create final in-memory-file
set table $AB_freq
plot $AB_tmp with table
unset table
# plot all results
plot $A_orig with points pointsize 2 title "A (original)",
$B_orig with points title "B (original)",
$A_bin with points title "A (binned)",
$B_bin with points title "B (binned)",
$A_uniq with linespoints title "A (binned,unique)",
$B_uniq with linespoints title "B (binned,unique)",
$AB_freq with linespoints title "A+B (binned,unique,frequency)"
# clean
undef $A_*
undef $B_*
undef $AB_*
The important trick is not only to use "set table", but finding out when to use plotstyle "with table" as well.
add a comment |
I will try to answer my own question since right now my problem seems to be solved.
Data setup
File: "A.dat"
2.3 8.2
3 7
4.3 6.3
1 9
3.3 7.3
2 8
4 6
1.3 9.1
File: "B.dat"
1.1 1.1
3 3
3.1 3.3
2 2
1 1
4.1 4.4
2.1 2.1
4 4
My solution relies heavily on "in-memory-files" (here-docs), but I assume (not testet!) it works with temporary files on disk as well.
The following script may not be very sophisticated, but it's working:
set xrange [0:5]
set yrange [0:*]
# simple binnig function (good enough for this demo)
binwidth = 1.0
bin(x) = binwidth * floor(x/binwidth)
# transfer original data to in-memory-files
set table $A_orig
plot "A.dat" with table
unset table
set table $B_orig
plot "B.dat" with table
unset table
# binning into new in-memory-file
set table $A_bin
plot $A_orig using (bin($1)):2
unset table
set table $B_bin
plot $B_orig using (bin($1)):2
unset table
# using in memory-files
# unique-filter: x -> avg(y)
set table $A_uniq
plot $A_bin smooth unique
unset table
set table $B_uniq
plot $B_bin smooth unique
unset table
# unite the different 'uniqued' datasets
# important: use plotstyle "with table"!
set table $AB_unite
plot $A_uniq with table,
$B_uniq with table
unset table
# apply smooth frequency (x->sum(y))
set table $AB_tmp
plot $AB_unite smooth freq
unset table
# create final in-memory-file
set table $AB_freq
plot $AB_tmp with table
unset table
# plot all results
plot $A_orig with points pointsize 2 title "A (original)",
$B_orig with points title "B (original)",
$A_bin with points title "A (binned)",
$B_bin with points title "B (binned)",
$A_uniq with linespoints title "A (binned,unique)",
$B_uniq with linespoints title "B (binned,unique)",
$AB_freq with linespoints title "A+B (binned,unique,frequency)"
# clean
undef $A_*
undef $B_*
undef $AB_*
The important trick is not only to use "set table", but finding out when to use plotstyle "with table" as well.
add a comment |
I will try to answer my own question since right now my problem seems to be solved.
Data setup
File: "A.dat"
2.3 8.2
3 7
4.3 6.3
1 9
3.3 7.3
2 8
4 6
1.3 9.1
File: "B.dat"
1.1 1.1
3 3
3.1 3.3
2 2
1 1
4.1 4.4
2.1 2.1
4 4
My solution relies heavily on "in-memory-files" (here-docs), but I assume (not testet!) it works with temporary files on disk as well.
The following script may not be very sophisticated, but it's working:
set xrange [0:5]
set yrange [0:*]
# simple binnig function (good enough for this demo)
binwidth = 1.0
bin(x) = binwidth * floor(x/binwidth)
# transfer original data to in-memory-files
set table $A_orig
plot "A.dat" with table
unset table
set table $B_orig
plot "B.dat" with table
unset table
# binning into new in-memory-file
set table $A_bin
plot $A_orig using (bin($1)):2
unset table
set table $B_bin
plot $B_orig using (bin($1)):2
unset table
# using in memory-files
# unique-filter: x -> avg(y)
set table $A_uniq
plot $A_bin smooth unique
unset table
set table $B_uniq
plot $B_bin smooth unique
unset table
# unite the different 'uniqued' datasets
# important: use plotstyle "with table"!
set table $AB_unite
plot $A_uniq with table,
$B_uniq with table
unset table
# apply smooth frequency (x->sum(y))
set table $AB_tmp
plot $AB_unite smooth freq
unset table
# create final in-memory-file
set table $AB_freq
plot $AB_tmp with table
unset table
# plot all results
plot $A_orig with points pointsize 2 title "A (original)",
$B_orig with points title "B (original)",
$A_bin with points title "A (binned)",
$B_bin with points title "B (binned)",
$A_uniq with linespoints title "A (binned,unique)",
$B_uniq with linespoints title "B (binned,unique)",
$AB_freq with linespoints title "A+B (binned,unique,frequency)"
# clean
undef $A_*
undef $B_*
undef $AB_*
The important trick is not only to use "set table", but finding out when to use plotstyle "with table" as well.
I will try to answer my own question since right now my problem seems to be solved.
Data setup
File: "A.dat"
2.3 8.2
3 7
4.3 6.3
1 9
3.3 7.3
2 8
4 6
1.3 9.1
File: "B.dat"
1.1 1.1
3 3
3.1 3.3
2 2
1 1
4.1 4.4
2.1 2.1
4 4
My solution relies heavily on "in-memory-files" (here-docs), but I assume (not testet!) it works with temporary files on disk as well.
The following script may not be very sophisticated, but it's working:
set xrange [0:5]
set yrange [0:*]
# simple binnig function (good enough for this demo)
binwidth = 1.0
bin(x) = binwidth * floor(x/binwidth)
# transfer original data to in-memory-files
set table $A_orig
plot "A.dat" with table
unset table
set table $B_orig
plot "B.dat" with table
unset table
# binning into new in-memory-file
set table $A_bin
plot $A_orig using (bin($1)):2
unset table
set table $B_bin
plot $B_orig using (bin($1)):2
unset table
# using in memory-files
# unique-filter: x -> avg(y)
set table $A_uniq
plot $A_bin smooth unique
unset table
set table $B_uniq
plot $B_bin smooth unique
unset table
# unite the different 'uniqued' datasets
# important: use plotstyle "with table"!
set table $AB_unite
plot $A_uniq with table,
$B_uniq with table
unset table
# apply smooth frequency (x->sum(y))
set table $AB_tmp
plot $AB_unite smooth freq
unset table
# create final in-memory-file
set table $AB_freq
plot $AB_tmp with table
unset table
# plot all results
plot $A_orig with points pointsize 2 title "A (original)",
$B_orig with points title "B (original)",
$A_bin with points title "A (binned)",
$B_bin with points title "B (binned)",
$A_uniq with linespoints title "A (binned,unique)",
$B_uniq with linespoints title "B (binned,unique)",
$AB_freq with linespoints title "A+B (binned,unique,frequency)"
# clean
undef $A_*
undef $B_*
undef $AB_*
The important trick is not only to use "set table", but finding out when to use plotstyle "with table" as well.
answered Feb 10 at 10:46
rascalrascal
1112
1112
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1403930%2fgnuplot-can-smooth-frequency-work-whole-file-including-multiple-datablocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown