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

  • Home
  • SEARCH
  • 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 7407279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:41:22+00:00 2026-05-29T05:41:22+00:00

I would like to plot results of classification and mark true classes. So, basically

  • 0

I would like to plot results of classification and mark true classes. So, basically what I need is to assign a color for each point base on value in a string column.

dataset looks like this:

5.1 3.5 1.4 0.2 Iris-setosa

I ended up with script following solution (thanks to the answer in here: How to make points one color when a third column equals zero, and another color otherwise, in Gnuplot?)

set palette model RGB defined (0 "red",1 "blue", 2 "green")
plot 'iris.data' using 1:2:5 notitle with points pt 2 palette

in the original dataset I replaced string labels with numbers, because I don’t know how to work with strings in gnuplot. Is there a way how to map string to colors?

Currently the output looks like this:
gnuplot coloring points

However I don’t like the gradient palette because it doesn’t make sense in this case. I would prefer normal legend with a single color and name of the class. Any idea how to do that?

  • 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-29T05:41:23+00:00Added an answer on May 29, 2026 at 5:41 am

    A way how you could do that is by using awk.

    Using a data file Data.csv:

    5.4452 4.6816 blue
    1.2079 9.4082 red
    7.4732 6.5507 red
    2.3329 8.2996 red
    3.4535 2.1937 green
    1.7909 2.5173 green
    2.5383 7.9700 blue
    

    and this script:

    set pointsize 3
    plot "< awk '{if($3 == \"red\") print}' Data.csv" u 1:2 t "red" w p pt 2, \
         "< awk '{if($3 == \"green\") print}' Data.csv" u 1:2 t "green" w p pt 2, \
         "< awk '{if($3 == \"blue\") print}' Data.csv" u 1:2 t "blue" w p pt 2
    

    you get this plot:

    enter image description here

    What awk does is simply check the third parameter of the data file and only print the line if it has some value: like red or blue.

    You would also get rid of the palette with the gradient.

    The script could be further improved by using gnuplot iterations.

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

Sidebar

Related Questions

I would like to plot results from a MDS analysis with 3 dimensions using
I would like to plot points in two dimensional fashion (each have an x
I would like to plot a vertical line (I'd prefer any orientation, but I'd
I would like to plot implicit equations (of the form f(x, y)=g(x, y) eg.
I would like to plot y1 and y2 in the same plot. x <-
I would like to plot the shifted logistic function as shown from Wolfram Alpha
I have a dataset with labels which I would like to plot with points
I would like to create pole/zero plot similar to pole/zero plot . It is
I would like to plot the greasy test signal in Matlab, and then plot
i would like to plot the following three functions in MATLAB using ezplot() but

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.