Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use data blocks to in-line data in the script #31

Open
epagone opened this issue Oct 18, 2021 · 4 comments
Open

Use data blocks to in-line data in the script #31

epagone opened this issue Oct 18, 2021 · 4 comments

Comments

@epagone
Copy link

epagone commented Oct 18, 2021

Since version 5 (released almost 7 years ago) gnuplot offers data blocks, a more flexible way to in-line data for repeated plotting. It might be worth using this new functionality.

@kookma
Copy link
Owner

kookma commented Nov 11, 2021

@epagone - thank you for your comments! ogpf uses data generated by Fortran!
Sometimes these output are large files like several hundred kb!

I am not sure what is the benefit of data block in the case of ogpf! but I would welcome to give some example and explain the purpose a little more!

Thank you

@epagone
Copy link
Author

epagone commented Nov 14, 2021

Thanks for looking into my issue.

Sometimes these output are large files like several hundred kb!

This makes even a better case for using data blocks (expanded description follows).

I am not sure what is the benefit of data block in the case of ogpf! but I would welcome to give some example and explain the purpose a little more!

If you look at the linked Stacked Overflow question in my first message both your requests are addressed. The main advantage is to avoid repeating the same entire dataset in the script for each plot command that is using it.

Currently, ogpf does something like (taken for the linked Stacked Overflow question):

set terminal gif
set output 'plot1.gif'
plot '-' using 1:2
        1 10
        2 20
        3 32
        4 40
        5 50
        e

and if you want to plot the same dataset with different plot specs you need to repeat the in-line data each time for each plot command.

With data blocks (in the example called $data), the data set is defined only once in the script and then can be re-used as many times as necessary:

$data << EOD
1 1
2 4
3 9
4 16
EOD

plot "$data" \
  with linespoints \
  title "my data"

I hope that it is now clearer.

The only drawback (as mentioned in my first message) is that this approach will fail with very old versions of gnuplot (i.e. older than about 7 years), but I guess that it is a reasonable request.

@kookma
Copy link
Owner

kookma commented Nov 14, 2021

@epagone thank you! If you can make a PR I welcome to look into it and merge!
If not let me to find some free time and do that!

We need to freeze the current version and start ne release to let people with old gnuplot can still use the library!

@epagone
Copy link
Author

epagone commented Nov 14, 2021

Thank you. Unfortunately, I do not see an opportunity in the next months, but I will try to have a look at this when things clear up a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants