0

I have two arrays "bitrates" and "psnr". I want to write a bash script to plot it.

bitrates=(1 2 3 4 5)

psnrArray=() psnr array is filled dynamically.

{ echo "${bitrates[*]}"; echo "${psnrArray[*]}"; } >Data
4
  • So, you wanna do something, you do it, and now you write about it on SO. Thanks for sharing! But where is your question? Commented Jan 22, 2018 at 10:39
  • Must-haves of all questions: ① What did you do? ② What did you expect to observe? ③ What did you observe instead? Commented Jan 22, 2018 at 10:40
  • How to plot it using gnuplot?. And also the data are in rows. I think it should be in columns. Commented Jan 22, 2018 at 10:41
  • I want a plot in which data from bitrates array will be in x axis and data from psnrarrays will be in y-axis. Commented Jan 22, 2018 at 10:42

1 Answer 1

2

Creating your data file can be done like this:

x=(1 2 3 4)
y=(5 6 7 8)
for ((i=0; i<${#x[@]}; i++))
do
  echo "${x[$i]}" "${y[$i]}"
done > data

Plotting using Gnuplot:

gnuplot -p -e "plot 'data' with lp"
Sign up to request clarification or add additional context in comments.

1 Comment

Less readable but shorter for creating the data file would be sth like: paste <(printf "%d\n" "${x[@]}") <(printf "%d\n" "${y[@]}") > data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.