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:
simple dot plot

Subject: simple dot plot

From: Roger

Date: 15 Jun, 2010 13:57:05

Message: 1 of 7

I have just started an applied statistics course and I need to do a simple dot plot on discrete data. I can find the histogram plots and many other plots but not a simple dot plot. Is there a matlab function that can do this?

Subject: simple dot plot

From: Steven Lord

Date: 15 Jun, 2010 14:07:53

Message: 2 of 7


"Roger " <roger.alms@yahoo.com> wrote in message
news:hv80rg$4aq$1@fred.mathworks.com...
>I have just started an applied statistics course and I need to do a simple
>dot plot on discrete data. I can find the histogram plots and many other
>plots but not a simple dot plot. Is there a matlab function that can do
>this?

By "dot plot" do you mean a SCATTER plot?

help scatter

Or if the "dots" are the same size, just plot individual points:

x = rand(1, 10);
y = rand(1, 10);
plot(x, y, 'o') % No line specifier in the LineSpec => no line

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: simple dot plot

From: sscnekro

Date: 15 Jun, 2010 14:08:06

Message: 3 of 7

Check out plot(x,y, properties) .. it is possible to off-set the line.
Eventually, scatter() .. less preferable.

Subject: simple dot plot

From: Rob Campbell

Date: 16 Jun, 2010 14:41:04

Message: 4 of 7

"sscnekro " <stiahni.mail@zoznam.sk> wrote in message <hv81g5$fn3$1@fred.mathworks.com>...
> Check out plot(x,y, properties) .. it is possible to off-set the line.
> Eventually, scatter() .. less preferable.

You might like this:
http://www.mathworks.com/matlabcentral/fileexchange/27582-rug-plots

Subject: simple dot plot

From: Brad Stiritz

Date: 18 Oct, 2013 03:05:06

Message: 5 of 7

Steve,

I'm wondering if you possibly might have misunderstood what the original poster was asking about? Please Google or look up Wikipedia "dot plot". Dot plots are not typical scatter plots, but rather histogram-like displays with stacked dots (or circles) rather than vertical bars.

It looks like MATLAB may not support dot plots out-of-the-box..?

Brad

"Steven Lord" <slord@mathworks.com> wrote in message <hv81fo$erl$1@fred.mathworks.com>...
>
> "Roger " <roger.alms@yahoo.com> wrote in message
> news:hv80rg$4aq$1@fred.mathworks.com...
> >I have just started an applied statistics course and I need to do a simple
> >dot plot on discrete data. I can find the histogram plots and many other
> >plots but not a simple dot plot. Is there a matlab function that can do
> >this?
>
> By "dot plot" do you mean a SCATTER plot?
>
> help scatter
>
> Or if the "dots" are the same size, just plot individual points:
>
> x = rand(1, 10);
> y = rand(1, 10);
> plot(x, y, 'o') % No line specifier in the LineSpec => no line
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>

Subject: simple dot plot

From: Steven Lord

Date: 18 Oct, 2013 14:32:11

Message: 6 of 7


"Brad Stiritz" <sorry.no.contact@info.net> wrote in message
news:l3q8h2$lb1$1@newscl01ah.mathworks.com...
> Steve,
>
> I'm wondering if you possibly might have misunderstood what the original
> poster was asking about?

Entirely possible. That's why I asked if they meant SCATTER. If you asked
someone non-technical (like my mother) to describe a scatter plot, she would
probably call it a dot plot or something similar; I didn't think that it was
a "technical term."

> Please Google or look up Wikipedia "dot plot". Dot plots are not typical
> scatter plots, but rather histogram-like displays with stacked dots (or
> circles) rather than vertical bars.

So that's the Wilkinson dot plot?

> It looks like MATLAB may not support dot plots out-of-the-box..?

I'm not sure. I'm not as familiar with the plot types Statistics Toolbox
provides as I am with the ones MATLAB provides. I think SCATTER is still the
right plotting tool to use; generating the Y coordinate data for each of the
"dots" is the tricky part. I whipped up something quick; I'm sure there's
room for improvement and enhancement (accepting S and C inputs that are
passed through to the SCATTER call, for instance.)


function h = dotplot(y)
% Generate a Wilkinson dot plot as per the description:
%
% http://en.wikipedia.org/wiki/Dot_plot_%28statistics%29
%
% Example:
% y = randi([5 15], 1, 100);
% h = dotplot(y);

if isempty(y)
    error('CSSM:dotplot:EmptyY', 'Y cannot be empty.');
end
uy = unique(y);
r = zeros(size(y));
upperLimit = 0;
for k = 1:length(uy)
    x = y == uy(k);
    r(x) = 1:nnz(x);
    upperLimit = max(upperLimit, nnz(x));
end
h = scatter(y, r);
% Give the dot plot some room so the dots aren't displayed on the axes box
axis([min(uy)-1, max(uy)+1, 0, upperLimit+1]);


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

Subject: simple dot plot

From: Brad Stiritz

Date: 20 Oct, 2013 23:18:12

Message: 7 of 7

Hi Steve,

Thanks for your reply. I think we're all on the same page now. Nice first cut with your code, thanks for taking the time to write & post. There are a couple of tweaks that would be needed to make the output look more like the Wilkinson dot plot:

1) Data need to be binned, e.g. via histc(), at least to some extent, so that closely matching values are offset & aligned in the y-direction & thus visually distinct. The following inputs should look very similar, but currently don't:

>> dotplot([1 3 4 5 2 1 1])
>> dotplot([1 3 4 5 2 1.02 1.04])

2) Dots need to be rendered much closer together. This should be a pretty simple matter of adjusting the y-axis scale & dot size.

3) Most of the dot plots I see in a Google Image search don't have y-axis ticks or labeling. Can these be suppressed in in MATLAB as well?

I submitted a SR asking the Statistics Toolbox developers to consider implementing a proper dot plot function.

Thanks,
Brad

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