File Exchange

image thumbnail


version (1.05 KB) by Ulrich Theune
Plots scattered data colorcoded and adds a colorbar.


Updated 20 Aug 2004

No License

This function is similar to MATLAB's own scatter3 routine. PLOTC(X,Y,V) plots the values specified in V as a color coded scatter plot at the locations specified in the vectors X and Y. The current colormap of the figure is used for the color code.

Cite As

Ulrich Theune (2021). plotc (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)


Hi, I am using the matlab v2016b. And this code doesn't work normally that the colormap always is only yellow. Any suggestions on how to solve this problem?


I am using this code with a dataset containing over 1,000,000 data points. The code doesn't seem to handle this many points very well and takes a long time to complete. Any suggestions on how to make it faster?? Otherwise, the code works great!


Chris Ride

better code

please read and try out this superb trik by Jos

Phil Tresadern wrote:
> skolpojken72 wrote:
>> How do i make MATLAB plot a 2D-graph and assign different
> to
>> each dot?
>> I want to plot a 2D-graph with pos_x and pos_y with pos_color.
>> With a command like this:
>> plot(pos_x, pos_y)
>> , I would want to do something like this:
>> plot(pos_x, pos_y, pos_color)
>> All vectors are the same length.
>> If you understand what i mean :-)
> Use the scatter function. This is *much* quicker than using
> multiple
> plots via 'hold'. Note that this works best using an indexed
> colormap.

If speed is an issue, this is really much quicker than scatter
approach, which itself is only marginally faster then the "hold on +
for loop".

h = plot(1,pos_y,'b.') ;
for i=1:length(pos_x),
set(h(i),'xdata',pos_x(i),'Color',pos_color(i,:)) ;

However, I agree that the OP is better helped with the
<scatter> solution.


piowc opgsw


MATLAB Release Compatibility
Created with R13SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: plotclr, color coded 2D scatterplot

Community Treasure Hunt

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

Start Hunting!