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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:28:58+00:00 2026-06-15T15:28:58+00:00

I have the following problem: I need to build the scatterplot of the data.

  • 0

I have the following problem: I need to build the scatterplot of the data. Everything nice, but there is some duplicate data there:

x = [11, 10, 3, 8, 2, 6, 2, 3, 3, 2, 3, 2, 3, 2, 2, 2, 3, 3, 2, 2];
y = [29, 14, 28, 19, 25, 21, 27, 15, 24, 23, 23, 18, 0, 26, 11, 27, 23, 30, 30, 25];

One can see that there are two elements with (2, 25); (2,27); (3,24);
So if to build this data with a regular scatter(x,y) I am loosing this information:
enter image description here

The way out of this I have found is to use undocumented 'jitter' parameter

scatter(x,y, 'jitter','on', 'jitterAmount', 0.06);

But I do not like the outlook:
enter image description here

What I was trying to achieve is this:

enter image description here

Where the number of duplicates is next to the point (if the number is more than 1), or may be inside the point.

Any idea how to achieve this?

  • 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-15T15:28:59+00:00Added an answer on June 15, 2026 at 3:28 pm

    You can do that pretty easily, let’s cut it down in two parts:

    First you’re gonna need to identify the unique 2d points and count them. That’s what we have the unique and accumarray function for. Read through the documentation if you don’t immediately understand what they’re doing and what outputs they have:

    x = [11 10 3  8  2  6  2  3  3  2  3  2  3  2  2  2  3  3  2  2];
    y = [29 14 28 19 25 21 27 15 24 23 23 18 0  26 11 27 23 30 30 25];
    A=[x' y'];
    
    [Auniq,~,IC] = unique(A,'rows');
    cnt = accumarray(IC,1);
    

    Now each row of Auniq contains the unique 2d points, while cnt contains the number of occurences of each of those points:

    >> [cnt Auniq]
    
    ans =
    
         1     2    11
         1     2    18
         1     2    23
         2     2    25
         1     2    26
         ...etc
    

    For displaying the number of occurences, there are a great many possibilities. As you mentioned, you could put the numbers inside/next to the scatter markers, other options are color encoding, size of the markers,… let’s do all of these, you can also of course combine!

    Number next to marker

    scatter(Auniq(:,1), Auniq(:,2));
    for ii=1:numel(cnt)
        if cnt(ii)>1
            text(Auniq(ii,1)+0.2,Auniq(ii,2),num2str(cnt(ii)), ...
                'HorizontalAlignment','left', ...
                'VerticalAlignment','middle', ...
                'FontSize', 6);
        end
    end
    xlim([1 11]);ylim([0 30]);
    

    enter image description here

    Number inside marker

    scatter(Auniq(:,1), Auniq(:,2), (6+2*(cnt>1)).^2); % make the ones where we'll put a number inside a bit bigger
    
    for ii=1:numel(cnt)
        if cnt(ii)>1
            text(Auniq(ii,1),Auniq(ii,2),num2str(cnt(ii)), ...
                'HorizontalAlignment','center', ...
                'VerticalAlignment','middle', ...
                'FontSize', 6);
        end
    end
    

    as you can see, I enlarged the size of the markers very simply with the scatter function itself.

    enter image description here

    Color encoding

    scatter(Auniq(:,1), Auniq(:,2), [], cnt);
    colormap(jet(max(cnt))); % just for the looks of it
    

    enter image description here

    after which you can add a colorbar or legend to indicate the number of occurences per color.

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

Sidebar

Related Questions

Hi every one I have the following problem I need to build a vector
Hi i have following Problem. I write a Mediawiki Extension where i need some
I have the following problem: 1) There is some abstract class A with several
I need to build ONE regular expression that can detect ALL the following strings
I have the following problem: I need to use XSLFO to generate a 2-column
I have a problem with Matlab - I need to do the following :
We have following problem. Developers frequently need to make small changes to our web
Following problem: I would like to build a little clipboard with jQuery. I have
In one of my projects I need to build an ASP.NET page and some
I need some help with query from multiple tables. My database: I have following

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.