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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:02:11+00:00 2026-05-25T19:02:11+00:00

I have some data in the following format: 10.0 1 a 2 10.2 2

  • 0

I have some data in the following format:

10.0 1 a 2
10.2 2 b 2
10.4 3 a 2
10.6 4 b 2
10.8 4 c 10
11.0 4 c 20

… where the third column basically indicates belonging to a ‘separate’ dataset; and so I would like to show, say, those samples belonging to ‘a’ in red, those belonging to ‘b’ in blue etc (using gnuplot Version 4.4 patchlevel 2).

I managed to somehow get the ‘sample’ style as a mix between ‘impulses‘ and ‘point‘ styles; and via Choosing line type and color in Gnuplot 4.0, managed to employ individual colors – this is how far I got (basictest.gnuplot):

#!/usr/bin/env gnuplot

print "Generating data..."

# to specify data inline in script:
# only system can work, as it is quoted;
# but still have to escape newlines!

system "cat > ./inline.dat <<EOF\n\
10.0 1 a 2\n\
10.2 2 b 2\n\
10.4 3 a 2\n\
10.6 4 b 2\n\
10.8 4 c 10\n\
11.0 4 c 20\n\
EOF\n"

print "done generating."


# set ranges
set yrange [0:30]
set xrange [0:4]

# define line styles - can call them up later
set style line 1 linetype 1 linewidth 3 pointtype 3 linecolor rgb "red"
set style line 2 linetype 1 linewidth 2 pointtype 3 linecolor rgb "green"
set style line 3 linetype 1 linewidth 2 pointtype 3 linecolor rgb "blue"


# offset the X axis: instead of 1:2, use: ($1-10):2
# to "mix", use "" for last datset - but must also repeat the "using"!
# ... and plot:

plot 'inline.dat' using ($1-10):2 with impulses linestyle 1,\
     "" using ($1-10):2 notitle with points linestyle 1,\
     "" using ($1-10):2 notitle with lines linestyle 2,\
     'inline.dat' using ($1-10):4 with impulses linestyle 3,\
     "" using ($1-10):4 notitle with points linestyle 3

# below just for saving file
#set terminal png
#set output 'basictest.png'
#replot

… which looks like this:

basictest.png

In other words, instead of the above – say for ($1-10):2, I’d like to see the 1st and 3rd sample (‘a’) in blue, 2nd and 4th sample (‘b’) in red, and the last two (‘c’) in green (I left the green line there just to see the effect of the style mixing).

I’m aware that this could be achieved by writing a script, that will parse the original data, and generate three tables out of that, as in:

10.0 1 a 2
10.4 3 a 2
---
10.2 2 b 2
10.6 4 b 2
---
10.8 4 c 10
11.0 4 c 20

… which could then be plotted ‘separately’ – but I was wandering if gnuplot maybe had some internal facility for something like that?

Thanks in advance for any answers,
Cheers!

 

PS: Some useful links for me:

  • gnuplot / intro / style Introduction to gnuplot — Plot Style
  • gnuplot / intro / plotexp (E) Introduction to gnuplot — Experimental Dat
  • Gnuplot: An Interactive Plotting Program
  • Gnuplot tricks: Further new features in gnuplot 4.4

 

EDIT: just wanted to post a link to a script with which I’m getting close to visualizing the data the way I wanted to:

basic-labels.png

I’m kinda wanting to treat the labels (with the added ‘points’ as rectagle backgrounds) as nodes in graphviz or in TikZ, and set up those nice connection lines between them – but even this already helps me much 🙂 Note that this is the wxt output – other terminals like png or pdfcairo will have a completely messed up rendering of boxes/labels (and would need to be tuned by hand).

  • 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-05-25T19:02:12+00:00Added an answer on May 25, 2026 at 7:02 pm

    It is possible. Gnuplot has a ternary operator like in C. Gnuplot also will ignore undefined expressions, such as logarithms of negative numbers or dividing by zero. Putting those together, you can plot only those lines that satisfy some particular condition by producing invalid numbers for those that fail to satisfy the condition. Simplifying a bit from the question, the approach looks like this:

    plot "inline.dat" using (strcol(3) eq 'a' ? $1 : 1/0):2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a log of following format << [ABC] some other data some other
I have some data formated like the following 2009.07.02 02:20:14 40.3727 28.2330 6.4 2.6
I have some data in a table that looks roughly like the following: table
I'm considering the following: I have some data stream which I'd like to protect
I have some data retrieved from web in following format (in a stream): {parts:[
I have some data in a dataset and I would normally select a record
I have some data in the following format: 1298501934.311 42.048 1298501934.311 60.096 1298501934.311 64.128
I have some data similar to the following chart: http://developer.yahoo.com/yui/examples/charts/charts-seriescustomization_clean.html Only difference is that
I have the following code in my application to load some data from my
I have the following situation: I have an application that collects some data from

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.