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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:46:59+00:00 2026-06-05T08:46:59+00:00

Hello All you Lovely People on stackoverflow, I am trying to plot data using

  • 0

Hello All you Lovely People on stackoverflow,

I am trying to plot data using gnuplot. I start by reading through a table and pulling out the data I want. I write this data to a .dat file. As of now, I’m just trying to plot it through a command line but will add the necessary code to plot it from the python script after it’s working.

My code which creates the .dat file-

#!/usr/bin/python

file = open("test_m.rdb")
table = open('table.dat', 'w+')

trash = file.readline()

trash = file.readline()

data = file.readline()
i = data.split()
flux = i[2]
observed = i[4]
table.write(flux + " " + observed,)

while 1:
    line = file.readline()
    i = line.split()
    try:
        flux = i[2]
        observed = i[4]
    except IndexError:
        break
    table.write("\n" + flux + " " + observed)
    table.close()

The command I’m attempting to use in cygwin and the error-

gnuplot plot table.dat

0.058 2
^
"table.dat", line 1: invalid command

Thank you in advance. I appreciate any suggestions you can offer.

  • 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-05T08:47:02+00:00Added an answer on June 5, 2026 at 8:47 am

    you probably want:

    gnuplot --persist -e 'plot "table.dat" u 1:2'
    

    With your command, gnuplot is looking for commands to run in a file called ‘plot’ and then in a file called ‘table.dat’. ‘table.dat’ doesn’t have commands to run, it has data to be plotted. using ‘-e’ is the same thing as putting the stuff in singe quotes into a temporary file (call it temp.gp) and then doing gnuplot temp.gp. The --persist makes it so the plot stays on your screen (which you’ll want since I doubt you’re saving it to a file). To learn about how to save it to a file, inside gnuplot do: help set term and help set output and set term.

    EDIT

    I don’t know much about cygwin, so I don’t know what the default terminal is (or what terminals will be enabled).

    A few things to try:

    gnuplot -e 'plot "table.dat" u 1:2; pause -1'  #this should leave your plot open until you hit return
    

    Put the commands in a file

    #tmp.gp
    set term postscript enh color
    set output "tmp.ps"
    plot "table.dat" u 1:2
    

    Now run it:

    gnuplot tmp.gp
    

    and then open the postscript using whatever tool you have for viewing postscripts — I often use gv, but I don’t know what there is on cygwin.

    gv tmp.ps &
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all i am reading one xlsx file using XSSF of Apche POI .
Hello all I'm using NSXMLParser to parse some xml data. I'm using this data
Hello all I am trying to work through (learn) MVC3 and I was playing
Hello to all in this lovely community, I am trying to get the contents
Hello all! This is my first post on stackoverflow. After hours of searching and
hello all this seems to be my problem I have a table in mysql
hello all its my first application using Zend Framework i have followed tutorial it
Hello all I am using MS SQL Server 2008 R2 and needed some help
Hello all Im trying to do a series of when checks to concat two
Hello All I am trying to flatten a list in Ocaml. I am a

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.