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

simple dot plot

112 views
Skip to first unread message

Roger

unread,
Jun 15, 2010, 9:57:05 AM6/15/10
to
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?

Steven Lord

unread,
Jun 15, 2010, 10:07:53 AM6/15/10
to

"Roger " <roger...@yahoo.com> wrote in message
news:hv80rg$4aq$1...@fred.mathworks.com...

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
sl...@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


sscnekro

unread,
Jun 15, 2010, 10:08:06 AM6/15/10
to
Check out plot(x,y, properties) .. it is possible to off-set the line.
Eventually, scatter() .. less preferable.

Rob Campbell

unread,
Jun 16, 2010, 10:41:04 AM6/16/10
to
"sscnekro " <stiahn...@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

Brad Stiritz

unread,
Oct 17, 2013, 11:05:06 PM10/17/13
to
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" <sl...@mathworks.com> wrote in message <hv81fo$erl$1...@fred.mathworks.com>...

Steven Lord

unread,
Oct 18, 2013, 10:32:11 AM10/18/13
to

"Brad Stiritz" <sorry.no...@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
sl...@mathworks.com

Brad Stiritz

unread,
Oct 20, 2013, 7:18:12 PM10/20/13
to
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
0 new messages