Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8998249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:59:55+00:00 2026-06-15T23:59:55+00:00

The folowing graph is generated with gnuplot: It shows 5 (but it can be

  • 0

The folowing graph is generated with gnuplot: enter image description here

It shows 5 (but it can be more or less) waves. However, what I need is display each wave separately, like this (I did with gimp):

enter image description here

Is there a way to do this with gnuplot? I also need that each wave be a different colour, as I have now.

Here is gnuplot script used: http://pastebin.com/vAD2syTS

Here is the python script that gnuplot script uses to fix my data: http://pastebin.com/WEncNjDA

Here is the data: http://pastebin.com/ewBpvHWM

Here is the data after python script fixes it: http://pastebin.com/cgimMyr9

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:59:56+00:00Added an answer on June 15, 2026 at 11:59 pm

    I had some fun with this one. My strategy involves plotting the first, last and intermediate plots with slightly different settings in order to get the borders to line up. I also define some functions to ensure that all the plot colors will indeed be different unless you have upwards of ~16 million data sets to plot.

    ### indices: change this parameter to equal the number of data sets to be plotted
    indices = 8 
    # h: height of output in pixels
    h = 150.0*indices
    # d: top and bottom margin in pixels
    d = 75.0
    
    ### define functions to help set top/bottom margins
    top(i,n,h,d) = 1.0 - (d+(h-2*d)*(i-1)/n)/h
    bot(i,n,h,d) = 1.0 - (d+(h-2*d)*i/n)/h
    
    ### define some fun RGB code converter functions
    
    # round: crude rounding function (gnuplot doesn't have this?)
    # assumes a float, returns an int
    round(x) = x-int(x)>=0.5?ceil(x):floor(x)
    
    # i2h: converts a (decimal) integer between 0 and 15 to hex.
    # returns a string, 0-F corresponding to 0-15
    i2h(i) = i==10?'A':i==11?'B':i==12?'C':i==13?'D':i==14?'E':i==15?'F':sprintf('%d',i)
    
    # i2r: converts an integer to an RGB code.
    # returns a string (RGB code) of length 6, 000000-FFFFFF corresponding to 0-16777215
    # changing the last division to 15 instead of 16 prevents colors being too faint
    i2r5(i) = i2h(i/(15**5))
    i2r4(i) = i2h(i%(16**5)/(15**4))
    i2r3(i) = i2h(i%(16**5)%(16**4)/(15**3))
    i2r2(i) = i2h(i%(16**5)%(16**4)%(16**3)/(15**2))
    i2r1(i) = i2h(i%(16**5)%(16**4)%(16**3)%(16**2)/(15**1))
    i2r0(i) = i2h(i%(16**5)%(16**4)%(16**3)%(16**2)%(16**1))
    i2r(i) = i2r5(i).i2r4(i).i2r3(i).i2r2(i).i2r1(i).i2r0(i)
    
    # rgb_iter: returns the i-th of n RGB codes, evenly spaced across the spectrum
    rgb_iter(i, n) = '#'.i2r(round((i-1)*(16777215.0/(n-1))))
    
    ### first set up some basic plot parameters
    set term png enhanced size 800,h font 'Courier-Bold,14'
    set output 'waves.png'
    
    set title 'Wave propagation by geophones'
    set ylabel 'Wave'
    
    set xrange [1400:]
    set yrange [-0.15:0.15]
    set ytics ('-0.1' -0.1, '0.0' 0.0, '0.1' 0.1)
    
    set key out right
    
    ### now make plots
    set multiplot layout indices,1
    
    ### first plot
    set border 14
    set tmargin at screen top(1,indices,h,d)
    set bmargin at screen bot(1,indices,h,d)
    unset xtics
    plot 'temp.dat' index 0 w lines lw 3 lc rgb rgb_iter(1,indices) title 'Geophone 1'
    unset title
    
    ### intermediate plots
    set border 10
    unset xlabel
    do for [i=1:indices-2] {
     set tmargin at screen top(i+1,indices,h,d)
     set bmargin at screen bot(i+1,indices,h,d)
     plot 'temp.dat' index i w lines lw 3 lc rgb rgb_iter(i+1,indices) title sprintf('Geophone %d', i + 1)
    }
    
    ### last plot
    set border 11
    set tmargin at screen top(indices,indices,h,d)
    set bmargin at screen bot(indices,indices,h,d)
    set xtics nomirror
    set xlabel 'Iterations'
    plot 'temp.dat' index (indices-1) w lines lw 3 lc rgb rgb_iter(indices,indices) title sprintf('Geophone %d', indices)
    
    unset multiplot
    

    The output on your sample data set looks like this:
    enter image description here

    The sizes of the top/bottom plots aren’t quite perfect, and as mgilson said it would probably take some fiddling with set xmargin at screen ... commands to make all the plot sizes equal.

    (If nothing else those int->RGB converter can be handy for specialized applications; I also have functions going from RGB codes to ints.)

    EDIT: I updated the script so all the plots will have the same height.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application contains a line graph which can display 20 or more datasets at
Here (jsfiddle) is my code with data. The graph generated is pretty messy can
I've generated a graph of random numbers (standard deviation 1, mean 0). I need
We have recently updated our open graph action to include user-generated photos but are
I have the following graph that I generated using ggplot2 I had finalPlot as
Currently in my app I can access my database of users, but now I
How can I generate a function call graph using Doxywizard with Graphviz installed? (I'm
I am using following code to load the graph generated by agraph class into
We have a state in our defects called Need More Information. I would like
I have written the following code to plot a graph but it is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.