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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:28:47+00:00 2026-05-26T13:28:47+00:00

I have a dataset with labels which I would like to plot with points

  • 0

I have a dataset with labels which I would like to plot with points colored according to their label. Is there a simple way how to get current line numer inside plot, so that I can determine which category does the point belong to?

I understood that x,y,z are the coordinates of plotted data, but it doesn’t help for the external labels.

This is quite ugly and it works just on sorted dataset with regular distribution.

    data = Import["http://ftp.ics.uci.edu/pub/machine-learning-databases/iris/iris.data"];
    data = Drop[data, -1]; (*there one extra line at the end*)
    inData = data[[All, 1 ;; 4]];
    labels = data[[All, 5]];
    ListPlot3D[inData,
      ColorFunction -> 
        Function[{x, y, z}, 
          If[y < 0.33, RGBColor[1, 1, 0.], 
               If[y < 0.66, RGBColor[1, 0, 0.], RGBColor[1, 0, 1]]
          ]
        ]
    ]

Expected result:

expected result of visualization

  • 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-26T13:28:47+00:00Added an answer on May 26, 2026 at 1:28 pm

    Suppose that points is the lists of coordinates and labels a list of the corresponding labels so for example

    points = Flatten[Table[{i, j, Sin[i j]}, 
       {i, 0, Pi, Pi/20}, {j, 0, Pi, Pi/10}], 1];
    labels = RandomChoice[{"label a", "label b", "label c"}, Length[points]];
    

    Each label corresponds to a colour which I’m writing as a list of rules, e.g.

    rules = {"label a" -> RGBColor[1, 1, 0], 
       "label b" -> RGBColor[1, 0, 0], "label c" -> RGBColor[1, 0, 1]};
    

    Then the points can be plotted in the colour corresponding to their label as follows

    ListPointPlot3D[Pick[points, labels, #] & /@ Union[labels], 
       PlotStyle -> Union[labels] /. rules]
    

    plot

    Edit

    To colour individual points in a ListPlot3D you can use VertexColors, for example

    ListPlot3D[points, VertexColors -> labels /. rules, Mesh -> False]
    

    colouring points in a ListPlot3D

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

Sidebar

Related Questions

In my WPF application, I have a collection to which I would like to
I have DataSet which has 3 columns. Name - insurance comp. name - treatmentDate
I have a DataSet which I get a DataTable from that I am being
I have a dataset that points to a View in my SQL database, and
I have a dataset which I want to use as a parameter for my
I'd like to sort a categorical variable my own way. I have grouped my
I have a DataSet which contains two tables, Publication and Owner, which are linked
I've created an ajax driven flot line chart that I would like to have
I have a simple web form which has a couple list boxes and a
I´m using a simple area chart based on a simple Dataset like this: DateTime(sql.timestamp)

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.