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 9281825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:12:57+00:00 2026-06-18T18:12:57+00:00

so I want to plot from a data file which has an undetermined number

  • 0

so I want to plot from a data file which has an undetermined number of fields of x and y data (of unknown but constant length). I want to plot them all together on one graph, BUT with different colors.

Without specifying the index, they all plot together with the same color.

Using a for-loop on the index or writing the indicies individually DOES plot them together with different colors, BUT the program will not know how many indicies to loop over.

Setting a really high number for the max of the for-loop works, but makes error messages when it runs out of data.

Is there any way to manipulate the data in gnuplot to derive the number of indices for the for-loop?

  • 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-18T18:12:58+00:00Added an answer on June 18, 2026 at 6:12 pm

    If you have gnuplot >= 4.6.0, you can use the stats command:

    #!/usr/bin/env gnuplot
    
    reset
    
    datafile = 'data.dat'
    
    set terminal png size 600,400
    set output 'test.png'
    
    stats datafile
    
    plot for [i=1:STATS_blocks] datafile index (i-1) pt 7 ps 2 title 'record '.i
    

    If your data looks like this (with two blank lines separating the data blocks)

    1 1
    
    
    2 2
    
    
    3 3
    
    
    4 2
    
    
    0 3
    

    That script will make this plot:

    enter image description here

    The same should apply for blocks of data with more than one (x,y) pair.

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

Sidebar

Related Questions

I have a data which I want to plot in cumulative function. The R
I have data in some text file which has let's say 10000 rows and
I have a data file where I want to plot specific lines of the
I have many files of data and I want to plot all of them
I am trying to plot a pie chart from a .txt file with data-set
I want to plot email from and to in world. For example, I received
I want to plot several lists of points, each list has distance (decimal) and
I have the data in two files. I want to plot a graph the
I have data from simulations in one single .dat file. Depending on certain criteria
I have a 3-tuple data set (X,Y,Z points) that I want to plot using

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.