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

Filling plot markers

1,995 views
Skip to first unread message

Evan

unread,
Feb 12, 2009, 4:47:01 PM2/12/09
to
I am trying to fill plot markers so that they automatically get filled with the same colour as the border. I have a for loop, so the colours of each plotted set of points are cycled through. However, with the following code does not fill the marker at all:

for b=8:14

subplot(2,1,1)

semilogx(f,a(b,:),'^','MarkerSize',9,'MarkerFaceColor','auto')
hold all

subplot(2,1,2)
semilogx(f,p(b,:),'^','MarkerSize',9,'MarkerFaceColor','auto')

hold all

end;

Any help on how to automatically fill the markers would be great.

Godzilla

unread,
Feb 12, 2009, 7:37:01 PM2/12/09
to
"Evan " <evan...@yahoo.ca> wrote in message <gn25cl$msh$1...@fred.mathworks.com>...

I think that cycling though colors works for multiple lines in a plot, not for multiple plots as you are doing.

Why not just set the colors yourself via an 'if' statement.

Steven Lord

unread,
Feb 12, 2009, 9:56:03 PM2/12/09
to

"Evan " <evan...@yahoo.ca> wrote in message
news:gn25cl$msh$1...@fred.mathworks.com...

>I am trying to fill plot markers so that they automatically get filled with
>the same colour as the border. I have a for loop, so the colours of each
>plotted set of points are cycled through. However, with the following code
>does not fill the marker at all:
>
> for b=8:14
>
> subplot(2,1,1)
>
> semilogx(f,a(b,:),'^','MarkerSize',9,'MarkerFaceColor','auto')

Look at what MarkerFaceColor 'auto' does:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/line_props.html#MarkerFaceColor

"auto sets the fill color to the axes color, or the figure color, if the
axes Color property is set to none (which is the factory default for axes)."

That line of code is doing what you asked it to do, not what you expected it
to do. If you set the MarkerFaceColor property to a ColorSpec:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/colorspec.html

it should work.

--
Steve Lord
sl...@mathworks.com


Evan

unread,
Feb 13, 2009, 8:22:01 AM2/13/09
to
So essentially what you are saying is that it is not possible to automatically fill marker shapes because the fill takes the properties of the axis rather than the line properties (which is what the outline of the marker takes). *facepalm*


I should just go through the trouble of trying to get GMT working on Windows. No need for extensive unnecessary looping there.


"Steven Lord" <sl...@mathworks.com> wrote in message <gn2ng3$g4t$1...@fred.mathworks.com>...

Steven Lord

unread,
Feb 13, 2009, 9:14:11 AM2/13/09
to

"Evan " <evan...@yahoo.ca> wrote in message
news:gn3s5p$ktv$1...@fred.mathworks.com...

> So essentially what you are saying is that it is not possible to
> automatically fill marker shapes because the fill takes the properties of
> the axis rather than the line properties (which is what the outline of the
> marker takes). *facepalm*

To me, the behavior of the 'auto' option for MarkerFaceColor seems
reasonable. I think that it does what most people want, which is to have
markers with just the edges colored. It's only a little bit harder to fill
them in with the same color as the line.


for b = 8:14
subplot(2, 1, 1);
h = semilogx(f,a(b,:),'^','MarkerSize',9);
set(h, 'MarkerFaceColor', get(h, 'Color'));
% etc
end


--
Steve Lord
sl...@mathworks.com


Evan

unread,
Feb 13, 2009, 9:50:18 AM2/13/09
to
Thanks, that worked. It seems needlessly complex for something that is automatically done by default in most other plotting programs I have used, such as Excel, Grapher or GMT. Perhaps it would be a good idea in future versions of Matlab to have a flag with 'MarkerFaceColor' that automatically fills plot markers with the same colour as the outline.

"Steven Lord" <sl...@mathworks.com> wrote in message <gn3v7j$hgm$1...@fred.mathworks.com>...

Janina Esins

unread,
Jun 10, 2010, 4:40:05 AM6/10/10
to
Hello :)

I have a similar problem, but different enough that this solution doesn't work for me :(
I have a 63x7 matrix which I want to plot, so I have 7 different lines with 63 points each in my plot. But I just want to use markers instead of lines, and I want them to be filled.
So my code so far is

plot(fancy-63x7-matrix,'o');

(Of course it's a bit more complicated. For example I wanted the markers to jitter a bit to not overlap. Therefore I added some random small noise to it, because I also couldn't find any jitter function. If there is one and you could tell me, I would be glad as well)

But back to the original problem. Is there a way to fill the markers? (I guess there is. I just couldn't find any, neither by searching the help, nor the internet)

Thanks a lot , and have a nice day :)

Janina Esins

unread,
Jun 10, 2010, 4:47:12 AM6/10/10
to

Janina Esins

unread,
Jun 10, 2010, 8:53:04 AM6/10/10
to
Ok, I found a solution, and it's quite easy and kind of whatever, that I didn't thought of it in the first place.

Instead of circle markers I just use point - markers and increase their size:

plot(fancy-63x7-matrix,'.','MarkerSize',16);

Maybe it helps if someone else is "standing on the line".

Have a nice day :)

Walter Roberson

unread,
Jun 10, 2010, 10:24:59 AM6/10/10
to
Janina Esins wrote:

> I have a 63x7 matrix which I want to plot, so I have 7 different lines
> with 63 points each in my plot. But I just want to use markers instead
> of lines, and I want them to be filled.
> So my code so far is
>
> plot(fancy-63x7-matrix,'o');

plot(fancy_63x7_matrix,'o','MarkerFaceColor','o')

Aditya

unread,
Jun 17, 2014, 3:58:07 PM6/17/14
to
Why would you use 'o' as your marker. Use '.' and increase the size. :)

Aditya

"Evan" wrote in message <gn25cl$msh$1...@fred.mathworks.com>...

Brad

unread,
Nov 4, 2016, 12:36:10 PM11/4/16
to
"Steven Lord" wrote in message <gn3v7j$hgm$1...@fred.mathworks.com>...
Steve Lord, I am utilizing 2015a, and had the same issue. Your solution appears to work just fine with my code. Thanks!
0 new messages