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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:05:18+00:00 2026-06-13T09:05:18+00:00

This is a minimal working example of the code I’m using: #!/bin/bash gnuplot <<

  • 0

This is a minimal working example of the code I’m using:

#!/bin/bash
gnuplot << EOF

set term postscript portrait color enhanced 
set encoding iso_8859_1
set output 'temp.ps'
set grid noxtics noytics noztics front
set size ratio 1
set multiplot
set lmargin 9; set bmargin 3; set rmargin 2; set tmargin 1

n=32    #number of intervals
max=13. #max value
min=-3.0    #min value
width=(max-min)/n        #interval width
hist(x,width)=width*floor(x/width)+width/2.0

set boxwidth width
set style fill solid 0.25 noborder

plot "< awk '{if (3.544068>=\$1) {print \$0}}' /data_file" u (hist(\$2,width)):(1.0) smooth freq w boxes lc rgb "red" lt 1 lw 1.5 notitle


EOF

which gets me this:

boxes

What I need is to use histeps instead, but when I change boxes for histeps in the plotcommand above, I get:

histeps

What is going on here??

Here’s the data_file. Thank you!


EDIT: If having histeps follow the actual outer bars limits instead of interpolating values in between (like boxesdoes) is not possible, then how could I draw just the outline of a histogram made with boxes?


EDIT2: As usual mgilson, your answer is beyond useful. One minor glitch though, this is the output I’m getting which when I combine both plots with the command:

plot "< awk '{if (3.544068>=\$1) {print \$0}}' data_file" u (hist(\$2,width)):(1.0) smooth freq w boxes lc rgb "red" lt 1 lw 1.5 notitle, \
"<python pyscript.py data_file" u 1:2 w histeps lc rgb "red" lt 1 lw 1.5 notitle

histo_shifted

Something appears to be shifting the output of the python script and I can’t figure out what it might be.
(Fixed in comments)

  • 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-13T09:05:20+00:00Added an answer on June 13, 2026 at 9:05 am

    The binning is quite easy if you have python + numpy. It’s a very popular package, so you should be able to find it in your distribution’s repository if you’re on Linux.

    #Call this script as:
    #python this_script_name.py 3.14159 data_file.dat
    
    import numpy as np
    import sys
    
    n=32         #number of intervals
    dmax=13.     #max value
    dmin=-3.0    #min value
    
    
    #primitive commandline parsing
    limit = float(sys.argv[1])   #first argument is the limit
    datafile = sys.argv[2]       #second argument is the datafile to read
    
    data = []    #empty list
    with open(datafile) as f:  #Open first commandline arguement for reading.
        for line in f:            #iterate through file returning 1 line at a time
            line = line.strip()   #remove whitespace at start/end of line
            if line.startswith('#'): #ignore comment lines.
                continue
            c1,c2 = [float(x) for x in line.split()] #convert line into 2 floats and unpack
            if limit >= c1:  #Check to make sure first one is bigger than your 3.544...
                data.append(c2) #If c1 is big enough, then c2 is part of the data
    
    counts, edges = np.histogram(data,               #data to bin
                                 bins=n,             #number of bins
                                 range=(dmin,dmax),  #bin range
                                 normed=False        #numpy2.0 -- use `density` instead
                                 )
    centers = (edges[1:] + edges[:-1])/2.  #average the bin edges to the center. 
    
    for center,count in zip(centers,counts):  #iterate through centers and counts at same time
        print center,count                    #write 'em out for gnuplot to read.
    

    and the gnuplot script looks like:

    set term postscript portrait color enhanced 
    set output 'temp.ps'
    set grid noxtics noytics noztics front
    set size ratio 1
    set multiplot
    set lmargin 9 
    set bmargin 3
    set rmargin 2 
    set tmargin 1
    
    set style fill solid 0.25 noborder
    
    plot "<python pyscript.py 3.445 data_file" u 1:2 w histeps lc rgb "red" lt 1 lw 1.5 notitle
    

    I’ll explain more when I get a little more free time …

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

Sidebar

Related Questions

I am having an issue converting type. I was trying code like this (minimal,
This is a minimal test case of some code that I actually have. It
I'm trying to execute this code (this is a minimal sample in order to
First here's what I'm using and trying to do: the minimal setup for this
Somehow, I can't seem to correctly implement a SortedMap. Here's a minimal (non-)working example:
Here is a minimal working example describing my current situation. The file main.cpp #include
A minimal illustrative Xcode project for this is available on github . On my
I mean something like this: http://www.globalscaletechnologies.com/p-25-sheevaplug-dev-kit-uk.aspx My minimal hardware requirement is: Ethernet card UPDATE:
I'm currently working on a minimal shop(-ish) script that has to deal with a
I am trying to prototype a GUI and created a minimal WPF project 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.