how can one assign specific colors to bars in scatterbar3?

조회 수: 37 (최근 30일)
Stephen
Stephen 2024년 11월 27일 16:48
댓글: Star Strider 2024년 12월 2일 16:23
I have created a 3D scatter bar plot using scatterbar3(X,Y,Z,width). The data for this plot is grouped into 5 categories. I'd like to color the bars in the plot according to the group from which that bar came.

채택된 답변

Star Strider
Star Strider 2024년 11월 27일 17:23
Edit the function to return the ‘h’ vector (of patch handles) and then experiment with setting the 'FaceColor' (and perhaps 'EdgeColor') of each one. That is a minor tweak to the function, and should allow you to change the relevant characteristics.
  댓글 수: 9
Stephen
Stephen 2024년 12월 2일 16:11
OK! Zap! Thanks, Star Rider! It works to change
set(h,'facecolor','flat','FaceVertexCData',z)
in scatterbar3.m to
set(h,'facecolor','r')
as you suggest.
Then, rather than running one complicated (for me) script altogether on a single set of grouped data, trying to change the color for each group, I siimply run scatterbar3 on each group, separately, using a different color.
For instance, after running scatterbar3 on one group using red bars, I run
hold on;
Then I simply change "r" to "b" in scatterbar3, as above,, and rerun on the next group of data using blue bars. Etc for green, and so forth. This adds each set of data to the same plot, color coded by group. That was my intent.
Kludgey, but it works!
Star Strider
Star Strider 2024년 12월 2일 16:23
As always, my pleasure!
Sometimes ‘kludgy’ is the best option (in my experience as well).
.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by