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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:01:50+00:00 2026-06-03T07:01:50+00:00

I have been searching all over the internet for an answer to this. It

  • 0

I have been searching all over the internet for an answer to this.

It seems there are many versions of how to plot color lines in gnuplot.
I have a data file that has 4 columns in it. I want to plot each column with a different color.
This is the snippet of code I am using per the gnuplot help file, but I get a syntax error when I use these.

set style line 1 lt 1 lc 1 lw 3 # red
set style line 2 lt 1 lc 2 lw 3 #green
set style line 3 lt 1 lc 3 lw 3 #blue
set style line 4 lt 1 lc 4 lw 3 #magenta

I have terminal set to postscript.

I have tried all combinations of this line type style including linestyle, and lc rgb ‘red’, for example, and none of them work!

Can anyone tell me what is wrong?

Let me clarify, this is a gnuplot script in a python script. code looks like this:

plot = open('plot.pg','w')
plot_script = """#!/usr/bin/gnuplot
reset
set terminal postscript 
#cd publienhanced color
set output "roamingresult.ps"
set xlabel "time (seconds)"
set xrange [0:900]
set xtics (0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900)
set ylabel "AP1         AP2         AP3       AP4"
set yrange [0:5]
set nokey
set grid
set noclip one
set ytics 1
#set style data boxes"""
set style line 1 lt 1 lc 1 lw 3
set style line 2 lt 1 lc 2 lw 3
set style line 3 lt 1 lc 3 lw 3
set style line 4 lt 1 lc 4 lw 3
  • 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-03T07:01:52+00:00Added an answer on June 3, 2026 at 7:01 am

    Okay, from the code you’ve just updated, your problem is clear.

    What’s wrong (quick answer)

    You’re including your Gnuplot script into the Python source code as a string. The """ token signifies the begininng of a string, as well as its end. The problem is that you terminate the string with this line:

    #set style data boxes"""
    

    Again, this triple quote syntax marks the end of the Gnuplot string, so what follows is expected to be Python code. Now, set means something entirely different to Python (it’s a mathematical set, if you’re curious). Your Gnuplot syntax for set does not match the meaning in Python, so this is why it’s giving you a syntax error.

    Moving the triple quotes to the end of your Gnuplot script would fix the problem. However, there is a much easier solution.

    A better way

    You should not be in-lining Gnuplot code directly into a Python script. Instead, you should read in the script from another file (where the file is entirely Gnuplot code), and deal with it that way.

    So, keep a file with just your Gnuplot code (e.g. plot.script):

    #!/usr/bin/gnuplot
    reset
    set terminal postscript 
    #cd publienhanced color
    set output "roamingresult.ps"
    set xlabel "time (seconds)"
    set xrange [0:900]
    set xtics (0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900)
    set ylabel "AP1         AP2         AP3       AP4"
    set yrange [0:5]
    set nokey
    set grid
    set noclip one
    set ytics 1
    #set style data boxes
    set style line 1 lt 1 lc 1 lw 3
    set style line 2 lt 1 lc 2 lw 3
    set style line 3 lt 1 lc 3 lw 3
    set style line 4 lt 1 lc 4 lw 3
    

    Then interact with this file in Python like so:

    plot_script = open("plot.script", "r").read()
    

    The End Result

    plot_script contains exactly the same data, each file contains code unique to one language, and your code is much more readable.

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

Sidebar

Related Questions

I have been searching all over but I can't find any answer to this.
Have been searching all over the internet but struggling to find my answer to
I have been searching for this all over the internet, this site claims that
I have been searching the internet wildly for an answer to this question. We
I have been searching all over the Internet, but did not find that exact
I have been searching all over the internet tonight, saw a lot of solutions
I've been searching all over for tips on this and have not really had
Have been searching over the Graph API docs, looking for the answer to this.
I have been searching google for over an hour and am frustrated, This seems
I have been searching all over the internet on how I could get the

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.