Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Varying bubble size in a scatter plot

560 views
Skip to first unread message

Jack

unread,
Oct 24, 2011, 9:44:29 AM10/24/11
to
Hi guys,

I am trying to create a scatter (bubble) plot that reflects the frequency of a set number of points by varying the size of the points.

For example, the first point would be point 0,0 with size 5, ideally, because the engine speed is 0, the torque is 0 and the amount of times this point occured is 5.

Is it possible to link the size of the points to the frequency matrix? This is what I have so far. But it doesn't work.

enginespeed = [0 0 0 0 1600 1600 1600 1600 2000 2000 2000 2000 2600 2600 2600 2600];
torque = [0 50 75 100 0 50 75 100 0 50 75 100 0 50 75 100];
frequency = [5 0 0 0 1 10 10 25 0 10 10 10 0 0 5 14];

figure(1)
scatter(enginespeed, torque, frequency)
xlabel('Engine speed / rpm')
ylabel('Torque / Nm')
title('Duty Cycle')
legend('frequency')

Is it possible to use the frequency matrix as the size of the bubbles?

Thank you for any help you can give me.

Steven_Lord

unread,
Oct 24, 2011, 2:22:15 PM10/24/11
to


"Jack " <jack_ra...@hotmail.com> wrote in message
news:j83q3t$2vi$1...@newscl01ah.mathworks.com...
> Hi guys,
>
> I am trying to create a scatter (bubble) plot that reflects the frequency
> of a set number of points by varying the size of the points.
> For example, the first point would be point 0,0 with size 5, ideally,
> because the engine speed is 0, the torque is 0 and the amount of times
> this point occured is 5.
>
> Is it possible to link the size of the points to the frequency matrix?
> This is what I have so far. But it doesn't work.

http://www.mathworks.com/help/techdoc/ref/scatter.html

"S determines the area of each marker (specified in points^2). S can be a
vector the same length as X and Y or a scalar."

> enginespeed = [0 0 0 0 1600 1600 1600 1600 2000 2000 2000 2000 2600 2600
> 2600 2600];
> torque = [0 50 75 100 0 50 75 100 0 50 75 100 0 50 75 100];
> frequency = [5 0 0 0 1 10 10 25 0 10 10 10 0 0 5 14];

You should scale these frequency values; you're not going to see much
difference between a marker that's 3 points on a side (10 points^2 is about
a 3-by-3 square) and one that's 5 points on a side (25 points^2), since a
point is 1/72 of an inch.

http://www.mathworks.com/help/techdoc/ref/rootobject_props.html#Units

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Jack

unread,
Oct 25, 2011, 5:05:30 AM10/25/11
to
Thank you Steven, I have since increased all the points size by a significant factor.

However, the problem of the zero value for frequency still persists. It doesn't allow me to plot the bubble plot using zero values for frequency.Therefore, is there a simple piece of code i could use to change the zeros into a different value, for example 0.001, so that the graph can be plotted but the zeros are so small that they can not be seen.

I am hoping to repeat this process a lot of times to create plots so a code would be very useful rather than just changing all the zeros to 0.001 manually.

Thank you for any help you can give me.


"Steven_Lord" <sl...@mathworks.com> wrote in message <j84aco$2m7$1...@newscl01ah.mathworks.com>...

Jack

unread,
Oct 25, 2011, 5:22:29 AM10/25/11
to
For example,

enginespeed = [0 0 0 0 1600 1600 1600 1600 2000 2000 2000 2000 2600 2600 2600 2600]
torque = [0 50 75 100 0 50 75 100 0 50 75 100 0 50 75 100]

frequency = [5 0 0 0 1 10 10 25 0 10 10 10 0 0 5 14]

frequency = 100.*frequency

if frequency == 0
frequency = frequency + 0.001;
end

figure(1)
scatter(enginespeed, torque, frequency, 'filled')
axis([0 3000 0 120])
xlabel('Engine speed / rpm')
ylabel('Torque / Nm')
title('Duty Cycle')
legend('residency')

But this doesn't work sadly

"Jack" wrote in message <j85u4q$8qv$1...@newscl01ah.mathworks.com>...

Steven_Lord

unread,
Oct 25, 2011, 9:34:19 AM10/25/11
to


"Jack " <jack_ra...@hotmail.com> wrote in message
news:j85v4l$bid$1...@newscl01ah.mathworks.com...
> For example,
> enginespeed = [0 0 0 0 1600 1600 1600 1600 2000 2000 2000 2000 2600 2600
> 2600 2600]
> torque = [0 50 75 100 0 50 75 100 0 50 75 100 0 50 75 100]
>
> frequency = [5 0 0 0 1 10 10 25 0 10 10 10 0 0 5 14]
>
> frequency = 100.*frequency
>
> if frequency == 0

This will only be satisfied if frequency is nonempty and ALL the elements of
frequency are equal to 0.

http://www.mathworks.com/help/techdoc/ref/if.html

> frequency = frequency + 0.001; end

Use logical indexing instead.

frequency(frequency==0) = 0.001;

Jack

unread,
Oct 26, 2011, 4:10:32 AM10/26/11
to
Thank you so much for your help, that worked perfectly.


"Steven_Lord" <sl...@mathworks.com> wrote in message <j86dsq$rhp$1...@newscl01ah.mathworks.com>...
0 new messages