No BSD License  

Highlights from
plotc

4.25

4.2 | 4 ratings Rate this file 20 Downloads (last 30 days) File Size: 1.87 KB File ID: #5718
image thumbnail

plotc

by Ulrich Theune

 

16 Aug 2004 (Updated 20 Aug 2004)

Plots scattered data colorcoded and adds a colorbar.

| Watch this File

File Information
Description

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.

Acknowledgements
This submission has inspired the following:
color coded 2D scatterplot, plotclr
MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
05 Apr 2005 piowc opgsw

ocn

22 Apr 2006 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
colors
> 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,:)) ;
end
 
However, I agree that the OP is better helped with the
<scatter> solution.
 
Jos

29 Aug 2008 Chris Ride  
07 Sep 2011 Jonathan  
07 Sep 2011 Erica

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!

Please login to add a comment or rating.
Updates
20 Aug 2004

??

Tag Activity for this File
Tag Applied By Date/Time
specialized Ulrich Theune 22 Oct 2008 07:30:12
plotting Ulrich Theune 22 Oct 2008 07:30:12
scatter Ulrich Theune 22 Oct 2008 07:30:12
colorbar Ulrich Theune 22 Oct 2008 07:30:12

Contact us at files@mathworks.com