how to specify filling properties in gscatter?

조회 수: 7 (최근 30일)
Zhe Dong
Zhe Dong 2024년 3월 30일
댓글: Voss 2024년 3월 30일
I'm trying to make a group scatter plot using gscatter function, there are two contrast groups each has three subgroups, is there a way I can seperate two contrast groups by filling or not filling the markers' interiors? here's a group example, how can I set female group with marker face filled while the male group is not?
group = {'female1','female2','femaler','male1','male2','male3'};

채택된 답변

Voss
Voss 2024년 3월 30일
편집: Voss 2024년 3월 30일
You can modify the required markers after calling gscatter. Here's an example:
% random data for 6 groups
N = 100;
Ngroups = 6;
x = rand(N,1);
y = rand(N,1);
g = randi(Ngroups,N,1);
% make the gscatter plot with filled markers
h = gscatter(x,y,g,[],'o','filled')
h =
6×1 Line array: Line (1) Line (2) Line (3) Line (4) Line (5) Line (6)
% make the markers for 3 of the groups un-filled
fill_idx = [1 2 3];
set(h(fill_idx),'MarkerFaceColor','none')
  댓글 수: 2
Zhe Dong
Zhe Dong 2024년 3월 30일
Thanks it worked pretty well!
Voss
Voss 2024년 3월 30일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by