1

I have several thousands of points to plot (about 10k) and I would like to plot them with Matlab but deciding a diferent size for each of the points (and a different color if possible). I tried to make a scatter plot for each point, but it is extremely slow compared to a single scatter call for all the points. Is there a way to plot several points in Matlab with different properties for each point, that works in a reasonable amount of time?

In case it is not possible to do it with Matlab, is there a way to do it with gnuplot?

1
  • 1
    Just for the reference, the 3D case of this question. Commented Jan 29, 2016 at 8:13

3 Answers 3

5

scatter(x, y, a, c) takes arguments x and y, and then a for size, and c for colour. a can either be a single scalar, or a vector with a size for each (x,y) point. c can be an RGB triplet, or a vector, the same size as x and y. For example:

x = 1:4;
scatter(x, x, 10*x, x);

results in

Example

So in your case, perhaps

scatter(xData, yData, [], 1:10000)

will result in your data having a different colour determined by its position in the data array.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice example! Better than the one based on random values that I was preparing :-)
@LuisMendo Thanks, only thing I was tempted to change with it is the colour of the last point a bit hard to see.
3

For gnuplot it's easy, suppose you write your datafile with 3 columns, all you have to do is

plot 'data.dat' u 1:2:3:3 with circles lc palette

HERE you can find some examples (for help type help circles).

If you want just what is called variable pointsize (pointsize is not related to the real axis) you can use:

plot 'data.dat' with points ps variable pt 7

HERE you can find some examples (for help type help pointsize).

Comments

2

For gnuplot you can combine pointsize variable and linecolor variable or linecolor palette:

set xrange [0:10]
set samples 21
plot '+' using 1:1:(0.2*$1):1 with point pointsize variable linecolor palette pt 7 notitle

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.