scatter3 -- plotting points with different colors attributes (2024)

5 views (last 30 days)

Show older comments

Roger Breton on 22 Dec 2021

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes

Commented: Matt J on 23 Dec 2021

I would like to explore a different approach with my scatter3 plotting project.

So far, I'm using a custom data tip to identify numerically colors (3D points) that are outside the gamut of my output device :

scatter3 -- plotting points with different colors attributes (2)

As you can see, there are points that clearly lie outside the 3D volume of the 'destination gamut'. For example, the data point shown above is 10.3511. Now, I'd to explore the possibility of adding a 'white outline' to those points, to further drive home the idea that they are out of gamut, for my students. What would be my best approach?

I was thinking, perhaps, to construct a loop to sub-select all the point that have less than, say, 1 DeltaE, and store them in a 'inGamut' array. And sending the rest in an 'outGamut' array, and use two calls to scatter3; one call for the inGamut points, followed by a second call, where I would specify additional attribute such as "outline" (or stroke -- don't know how it's called in Matlab) for the outGamut points.

It's either than or go through all the points in a loop and have them plotted differently depending on their DeltaE value.

Which would be a good (easiest) approach?

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (1)

Matt J on 22 Dec 2021

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#answer_860510

Edited: Matt J on 23 Dec 2021

Open in MATLAB Online

The first option sounds the closest to what I would do, except that I see no reason to use a loop. Just use logical indexing:

in=DE76<1; out=~in;

inGammut={X(in), Y(in), Z(in)};

outGammut={X(out), Y(out), Z(out)};

hold on

scatter3(inGammut{:},80,RGB,'filled');

scatter3(outGammut{:},_____);

hold off

5 Comments

Show 3 older commentsHide 3 older comments

Roger Breton on 23 Dec 2021

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1900875

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1900875

Thank you Matt,

I experimented with a loop and, boy!, did that take forever :-) I had to interrupt execution...

Is the first line above some kind of pseudocode? I never seen this notation.

I confess my ignorance in Matlab... So far, I managed to get this far :

DE76reshape = reshape(DE76, [12, 1])

myTable = table(Lab(1,:)', Lab(2,:)',Lab(3,:)', DE76reshape)

inGamutTable = myTable(myTable.DE76reshape < 1,:)

First, as you can see, the DE76 was a 4 x 3 array. So I converted it to a column vector. Then I created a table made up of the three column vectors from my Lab array (which I transposed with the apostrophe operator) plus the DE76 column vector. At that point, I extracted the colors meeting my criteria using the third statement above.

The table has only value in finding colors that have than 1 DeltaE value. But once I get that table, then I need to turn it back into compatible arguments for the scatter3 function... Which I'm having difficulty with...

Matt J on 23 Dec 2021

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1900955

Edited: Matt J on 23 Dec 2021

Open in MATLAB Online

You don't need the table at all. The only pseudocode in what I had above is the 2nd call to scatter3(). You need to fill in the blank with whatever arguments you want to use for the outGammut points.

[X,Y,Z]=deal(Lab(1,:), Lab(2,:),Lab(3,:));

in=(DE76(:)<1); out=~in;

inGammut={X(in), Y(in), Z(in)};

outGammut={X(out), Y(out), Z(out)};

hold on

scatter3(inGammut{:},80,RGB,'filled');

scatter3(outGammut{:},_____);

hold off

Roger Breton on 23 Dec 2021

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901680

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901680

Thank you, Matt, for your new reply :-)

Please allow me to follow at my own pace (I'm not a rocket scientist...)

I found the "deal" function in Matlab's Help but I'm not sure what it does. I guess you are taking my initial Lab values as input and transforming them in some way? Many Matlab's functions are not for the faint of heart...

When you issue in=(DeltaE(:)<1), I don't follow? Doesn't DeltaE need two arguments? I confess I'm not familiar with the super compact notation but your statement doesn't seem to have any arguments at all?

Roger Breton on 23 Dec 2021

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901755

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901755

Open in MATLAB Online

By the way...

I tried running your code in a new script.

I wasn't expecting the deal function would break down the Lab [3 x n] variable (row1=L, row2=a, row3=b) into separate row vectors -- neat!

But the compiler complains that it does not recognize the 'deltaE' function :

Unrecognized function or variable 'deltaE'.

I suspect it needs a second argument, somehow...

Matt J on 23 Dec 2021

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901760

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/1616275-scatter3-plotting-points-with-different-colors-attributes#comment_1901760

Where I had DeltaE, I really meant DE76.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABLanguage FundamentalsLoops and Conditional Statements

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

  • scatter3
  • deltae
  • loop

Products

  • Image Processing Toolbox

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


scatter3 -- plotting points with different colors attributes (9)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

scatter3 -- plotting points with different colors attributes (2024)

FAQs

What is scatter3 colors in Matlab? ›

scatter3( X , Y , Z , S , C ) specifies the circle colors. You can specify one color for all the circles, or you can vary the color. For example, you can plot all red circles by specifying C as "red" . scatter3(___, 'filled' ) fills in the circles, using any of the input argument combinations in the previous syntaxes.

How to give color to plot in Matlab? ›

RGB Triplet — Create a custom color by specifying a three-element row vector whose elements are the intensities of the red, green, and blue components of a color. The intensities must be in the range [0,1] . For example, you can specify a shade of pink as [1 0.5 0.8] .

What is the size of the dot in scatter3? ›

Draw a 3-D scatter plot. A marker is plotted at each point defined by the coordinates in the vectors x , y , and z . The size of the markers is determined by s , which can be a scalar or a vector of the same length as x , y , and z . If s is not given, or is an empty matrix, then a default value of 8 points is used.

How to change marker color in Matlab? ›

You can use the linespec argument to specify a named color, but to specify a custom color, set an object property. For example, Line objects have a Color property. Create a plot with a purple line that has circular markers. Specify only the line and marker symbols in the linespec argument.

What are the different colors in MATLAB? ›

Possible color values are 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'gray', 'lightBlue', 'orange', 'darkGreen'.

How many colors are there in MATLAB? ›

To determine the bit depth of your system's screen, enter this command at the MATLAB prompt. 8-bit displays support 256 colors. An 8-bit display can produce any of the colors available on a 24-bit display, but only 256 distinct colors can appear at one time.

How do you specify a color in a plot? ›

All of the line properties can be controlled by keyword arguments. For example, you can set the color, marker, linestyle, and markercolor with: plot(x, y, color='green', linestyle='dashed', marker='o', markerfacecolor='blue', markersize=12).

How do you add color to a surface plot in MATLAB? ›

Specify Colormap Colors for Surface Plot

Specify the colors for a surface plot by including a fourth matrix input, C . The surface plot uses Z for height and C for color. Specify the colors using a colormap, which uses single numbers to stand for colors on a spectrum. When you use a colormap, C is the same size as Z .

How to display color image in MATLAB? ›

To display a truecolor image, call the imshow function or open the Image Viewer app. For example, this code reads a truecolor image into the MATLAB workspace and then displays the image. This sample code uses the variable name RGB to represent a truecolor image in the workspace.

How to increase scatter plot dot size? ›

One way to adjust the marker size in a scatter plot is by using the 's' parameter in the plt. scatter() function. The 's' parameter allows you to specify the size of the markers in points. In this example, we have defined three lists: 'x', 'y', and 'marker_size'.

What is the marker size in scatter3d? ›

scatter3d(x,y,z) creates a scatter plot with markers at the locations specified by x , y , and z . The default type of the marker is a circle, the default color is "blue" and the default marker size is 36. This means the circle surrounding the marker has an area of 36 points squared.

How wide are dot markers? ›

Dot markers are available in three sizes:

Small: 5-8mm. Standard: 10-13mm. Extra Large: 18-23mm.

How do you color with marker techniques? ›

Color from Light to Dark:

START LIGHT! You can always add more color and go darker, but you can't go to the opposite way. Color in the lightest shades first, then build up darker colors. Try to plan out highlights in advance and know which areas you're going to keep white (you can't erase marker!)

How do Colour changing markers work? ›

COLOR CHANGING MARKERS: The color changing markers use a fun blending technology where layering one color on top of another creates an entirely new third color, allowing kids to explore new hues and color combinations.

What is a scatter plot in MATLAB? ›

A scatter plot is a simple plot of one variable against another. The MATLAB® functions plot and scatter produce scatter plots. The MATLAB function plotmatrix can produce a matrix of such plots showing the relationship between several pairs of variables.

What is a 3 dimensional scatter plot? ›

3D scatter plots are used to plot data points on three axes in the attempt to show the relationship between three variables. Each row in the data table is represented by a marker whose position depends on its values in the columns set on the X, Y, and Z axes.

What is the colorize function in MATLAB? ›

___ = colorize(___, Name,Value ) specifies options using one or more name-value pair arguments in addition to any combination of arguments from previous syntaxes. Use this syntax to specify the options to estimate false-colored and color-infrared (CIR) images of the input data.

What is an indexed color image in MATLAB? ›

An indexed image consists of an image matrix and a colormap. A colormap is a c-by-3 matrix of data type double with values in the range [0, 1]. Each row of the colormap specifies the red, green, and blue components of a single color. The pixel values in the image matrix are direct indices into the colormap.

Top Articles
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 6351

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.