Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot changes colour with time

Subject: plot changes colour with time

From: Hovito S

Date: 15 Nov, 2009 10:07:02

Message: 1 of 4

Hi. I am pretty new to Matlab and I am studying some data. I am plotting two variables against each other using the 'scatter' function, but would like to see, in two dimensions, the scatter plot changing colour as time progresses. For example, the first 5 seconds in blue, the nexxt 5 seconds in red, the next 5 seconds in green, etc. I am pretty sure that this would involve the 'hold' function but I'm not completely sure how to do this. I have posted code from an example of one of the scatter plots I am currently using below.

Thanks for any help (like I said, I am a bit of a newb)

scatter(sine_current,sine_pressure,'DisplayName','sine_current vs sine_pressure','XDataSource','sine_current','YDataSource','sine_pressure');
title('Sine Current vs Sine Pressure');
xlabel('Sine Current');
ylabel('Sine Pressure');

Subject: plot changes colour with time

From: Joerg Buchholz

Date: 15 Nov, 2009 10:33:01

Message: 2 of 4

"Hovito S" <hovitocarter@googlemail.com> wrote in message <hdojs5$jij$1@fred.mathworks.com>...
> Hi. I am pretty new to Matlab and I am studying some data. I am plotting two variables against each other using the 'scatter' function, but would like to see, in two dimensions, the scatter plot changing colour as time progresses. For example, the first 5 seconds in blue, the nexxt 5 seconds in red, the next 5 seconds in green, etc. I am pretty sure that this would involve the 'hold' function but I'm not completely sure how to do this. I have posted code from an example of one of the scatter plots I am currently using below.
>
> Thanks for any help (like I said, I am a bit of a newb)
>
> scatter(sine_current,sine_pressure,'DisplayName','sine_current vs sine_pressure','XDataSource','sine_current','YDataSource','sine_pressure');
> title('Sine Current vs Sine Pressure');
> xlabel('Sine Current');
> ylabel('Sine Pressure');

This should give you an idea:

scatter ([1 2 3 4 5], [1 2 3 2 1], [42 42 42 42 42], [1 2 3 4 5])

Subject: plot changes colour with time

From: Hovito S

Date: 15 Nov, 2009 15:37:01

Message: 3 of 4

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <hdolct$3vr$1@fred.mathworks.com>...
>
> This should give you an idea:
>
> scatter ([1 2 3 4 5], [1 2 3 2 1], [42 42 42 42 42], [1 2 3 4 5])

Thanks for that. I understand what each of those four parts does for the scattergram, however, my problem with this method is that the two sets of data that I am plotting against each other are data sets containing around 1,000,000 data points. Is there a way for me to get, for example, the first 1000 in red, the next 1000 in blue and so on by using this method or should I use a different method. I have a feeling I am being stupid here and missing something really obvious :s.

Thanks a lot.

Subject: plot changes colour with time

From: Joerg Buchholz

Date: 15 Nov, 2009 15:56:01

Message: 4 of 4

"Hovito S" <hovitocarter@googlemail.com> wrote in message <hdp76t$hhh$1@fred.mathworks.com>...
> "Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <hdolct$3vr$1@fred.mathworks.com>...
> >
> > This should give you an idea:
> >
> > scatter ([1 2 3 4 5], [1 2 3 2 1], [42 42 42 42 42], [1 2 3 4 5])
>
> Thanks for that. I understand what each of those four parts does for the scattergram, however, my problem with this method is that the two sets of data that I am plotting against each other are data sets containing around 1,000,000 data points. Is there a way for me to get, for example, the first 1000 in red, the next 1000 in blue and so on by using this method or should I use a different method. I have a feeling I am being stupid here and missing something really obvious :s.
>
> Thanks a lot.

scatter (1:3000, rand(1,3000), 42*ones(1,3000) , [1*ones(1,1000), 2*ones(1,1000), 3*ones(1,1000)])

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us