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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:24:27+00:00 2026-06-14T04:24:27+00:00

I am encountering strange behavior on my gnuplot script. The objective of this script

  • 0

I am encountering strange behavior on my gnuplot script. The objective of this script is to read in a file and plot a specific set of lines (3 consecutive lines based on a given start point in the file) using the very first line of the file as the series headers.

While the plot works conceptually, I am encountering a large insert into the image on the left side, as if an empty line is read and plotted as 0 (with no header)

Input File:

Level,Filter,Type,Set1,Set2,Set3
Level1,Filter1,Type1,112,186,90
Level1,Filter1,Type2,233,335,159
Level1,Filter1,Type3,224,332,157

Code:

set terminal postscript color
set output '| epstopdf --filter --outfile=output.pdf'

set boxwidth 0.5
set style fill solid
set style data histograms

set datafile separator "," 

LINE1 = 1 + 3 * COUNT
LINE2 = LINE1 + 1
LINE3 = LINE1 + 2

plot '../test.csv' \
u ( ( int($0) == LINE1 || int($0) == LINE2 || int($0) == LINE3)? $4 : 1/0) ti col,'' \
u ( ( int($0) == LINE1 || int($0) == LINE2 || int($0) == LINE3)? $5 : 1/0) ti col,'' \
u ( ( int($0) == LINE1 || int($0) == LINE2 || int($0) == LINE3)? $6 : 1/0) ti col

Command Line Call

>gnuplot -e "COUNT=0" test.plot

How can I get rid of the empty fields that lead to the right shift?

My gnuplot version is 4.6.

  • 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-14T04:24:29+00:00Added an answer on June 14, 2026 at 4:24 am

    Since you’re already using pipes and unix-ish tools, I would use sed here as well:

    set term post color
    set output 'foo.ps'
    
    set style data histograms 
    set style histogram clustered 
    
    set datafile separator ","     
    
    set boxwidth 0.5
    set style fill solid
    
    SED_CMD = sprintf('< sed -n -e 1p -e %d,%dp test.csv',COUNT*3+2,COUNT*3+4)
    
    plot for [COL=4:6] SED_CMD u COL ti col
    

    I’ve simplified a lot of things while I was trying to figure out what your script was doing — I used plot iteration (introduced in gnuplot 4.3). Originally I had thought that plot '...' every ... would work, but histograms seem to choke on every and I don’t (yet!) understand why.

    Here’s an explanation of the sed command:

    -e 1p      #print first line in file
    -e %d,%dp  #print n'th line through m'th line (inclusive) where n=COUNT*3+2 and m=COUNT*3+4
    

    If you’re worried about shell injection, this seems to be safe as well:

    gnuplot -e 'COUNT=";echo hi"' -persist test.gp
    "test.gp", line 10: Non-numeric string found where a numeric expression was expected
    

    Gnuplot will only write numbers to your command string.

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

Sidebar

Related Questions

So I am seemingly encountering some strange behavior when using NSString 's -sizeWithFont family
I've been encountering some strange behavior when trying to find a key inside a
I am encountering a strange problem with my script which I am testing to
I am encountering a strange issue with the commons-io/java-io. Essentially my file creation is
I seem to be encountering a strange issue in Objective-C converting a float to
Unexpected behavior: I am encountering strange behavior of Oracle sequences with 11g (works with
I am encountering some strange behavior with using the matplotlib.pyplot ginput() function to store
I'm encountering a strange behavior of MySQL. Query execution (i.e. the usage of indexes
I'm encountering a strange problem when i try to compile a DTO file which
I'm encountering a strange issue in an ANT file I use for building 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.