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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:34+00:00 2026-06-04T17:31:34+00:00

I’m absolutely new to gnuplot and did not find a working solution after googling.

  • 0

I’m absolutely new to gnuplot and did not find a working solution after googling.

I have a data matrix looking something like this:

  A B C D E
A 0 2 3 4 5
B 6 0 8 9 0
C 1 2 0 4 5
D 6 7 8 0 0
E 1 2 3 4 0

What I would like to do is plotting a heatmap with plot 'result.csv' matrix with image, with the x-axis labeled with A-E and the y-axis labeled with A-E. This matrix does not always have the same size, but the number of row always equals the number of cols and it’s always labeled.

Could someone help me out with this? I guess I have to use the using command, but up to now this appears like complete voodoo to me…

Thanks a lot!

  • 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-04T17:31:35+00:00Added an answer on June 4, 2026 at 5:31 pm

    This one is actually a doosie and I can’t make it happen without some *nix shell magic.

    First, we want to get the x tic labels and y tic labels:

    XTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' test.dat`"
    YTICS="`head -1 test.dat`"
    

    At this point, XTICS is the string “F G H I J” and YTICS is the string “A B C D E”.

    Now, we want to set the xtics by iteration:

    set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
    set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )
    

    We’ve used 2 gnuplot builtin functions (word and words). words(string) counts how many words there are in the given string (a word is a character sequence separated by spaces). word(string,n) returns the n’th word in the string.

    Now, we can plot your datafile … The only problem is that matrix wants to use all rows and columns in your datafile. You might be able to cut down the rows/columns actually read by using the every keyword, but I don’t know how to do that on matrix files — and I think it’s probably easier to just keep on relying on shell utilities (awk and sed)

    plot "<awk '{$1=\"\"}1' test.dat | sed '1 d'" matrix w image
    #######^ replace the first field with nothing
    ################################## ^ delete first line
    

    And now your plot (hopefully) looks the way you want it to.

    Also note that since we have used iteration, this script will only work in gnuplot 4.3 or higher — Since the current stable is 4.6, hopefully that’s Ok.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.