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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:39:39+00:00 2026-05-27T16:39:39+00:00

Im faced with a problem where i need to plot a two dimensional data

  • 0

Im faced with a problem where i need to plot a two dimensional data with different colors and markers.

We are given with 2 array, namely points (n x 2 dimension) and Label (n x 1 dimension). Im not sure about the number of unique values in the Label array but maximum could be 10. I would like to plot the points with different color and markers based on its corresponding Label value.

Can any one help me in this regard

  • 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-27T16:39:40+00:00Added an answer on May 27, 2026 at 4:39 pm

    Use gscatter, which does a scatter plot, using a group (Label in your case) to plot in different colours/makers.

    GSCATTER(X,Y,G,CLR,SYM,SIZ) specifies the colors, markers, and
        size to use.  CLR is either a string of color specifications or
        a three-column matrix of color specifications.  SYM is a string
        of marker specifications.  Type "help plot" for more information.
        For example, if SYM='o+x', the first group will be plotted with a
        circle, the second with plus, and the third with x.  SIZ is a
        marker size to use for all plots.  By default, the marker is '.'.
    

    So you can specify colours like 'rgcmykwb' to do red for the first group, green for the second, etc or [] just to have Matlab sort it out.

    By default Matlab uses the same marker for each group, so you need to specify what markers you want to be used for each group. If you do '.ox+*sdv^<>ph' you’ll just cycle along all the markers that Matlab has.

    n=50;
    % make nx2 matrix of random points.
    points = random('unif',0,1,n,2);
    % make nx1 matrix of random labels from {1,2,...,5}
    labels=round(random('unif',1,5,n,1));
    
    % plot. Let Matlab sort out the colours and we will specify markers.
    gscatter(points(:,1),points(:,2),labels,[],'ox+*sdv^<>ph.')
    

    It looks a bit like this:
    enter image description here

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

Sidebar

Related Questions

I faced a problem - I need to use a macro value both as
I am faced with a unique problem and probably need some external help and
I am faced with the following programming problem. I need to generate n (a,
I am currently faced with a problem where I need to execute a batch
I faced with problem that geomap by google fails with JQuery together in Internet
I faced a problem while using threading for the first time, In an SWT
I have faced this problem quite often during the last couple of months, during
I recently faced a problem of presenting the output of simple genetic algorithm that
We've faced strange problem. We have log on service, that authenticates user, adds auth
Today I faced a strange problem in C#. I have an ASP.NET page where

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.