필터 지우기
필터 지우기

How can I set transparency in 2D plot?

조회 수: 17 (최근 30일)
ccs
ccs 2015년 3월 4일
답변: Peter Rochford 2017년 11월 28일
I have lots of data points overlaid. I would like to know if the is a way in matlab to set the transparency of my plot to be able to visualize the density clearly?
Thanks

채택된 답변

Chris McComb
Chris McComb 2015년 3월 4일
I don't think there's a way to make markers transparent. However, you could plot each data point as a small circle (using patch), and then set the transparency of the patch. This may be relevant if you go that direction: http://stackoverflow.com/questions/5893513/plot-circles-with-alpha-values-in-matlab
  댓글 수: 4
Carl Witthoft
Carl Witthoft 2016년 1월 28일
I tested that referenced code in R2015a with complete success.
Mike Garrity
Mike Garrity 2016년 1월 28일
You can't set the transparency of the markers that plot creates. In fact, plot doesn't really have any support for transparency yet.
But as of R2015b, you can set transparency for the markers that scatter creates. That means that you could do this:
x = 1:10;
y = rand(1,10);
h = plot(x,y);
hold on
scatter(x,y,150,'filled', ...
'MarkerFaceAlpha',3/8,'MarkerFaceColor',h.Color)
hold off

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

추가 답변 (1개)

Peter Rochford
Peter Rochford 2017년 11월 28일
I have written a collection of Matlab functions for creating semi-transparent markers in plots and legends. The files are available from MATLAB Central as the MarkerTransparency package. A few examples of how to use these functions are included in the download and there is also a Wiki on GitHub. A major benefit of this package is it enables the user to have the semi-transparent markers also appear in the legend.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by