필터 지우기
필터 지우기

How can I create a scatterplot and map the outputs to a logarithmic colorscale?

조회 수: 17 (최근 30일)
I want to create a scatterplot like the picture included, where the color of the output is mapped to a color on a logarithmic scale. I initially tried using a for loop with conditional statements and using the built in colors ('r','g','b','y', etc), but I want to have a larger variation of colors that change in intensity based on the output value of the point. Is this possible in MATLAB?

채택된 답변

Kevin Holly
Kevin Holly 2021년 9월 29일
You can change the colorbar's scale to logarithmic with the following command:
set(gca,'ColorScale','log')
Here is it altogether with random values for y.
x = 1:1000;
y = 100000*rand(1,1000).*rand(1,1000).*rand(1,1000);
scatter(x,y,20,y,'filled')
ah=gca;
ah.YScale = 'log';
colorbar
set(gcf,'color','k')
set(gca,'color','k')
ah.XAxis.Color = 'w';
ah.YAxis.Color = 'w';
fh=gcf;
fh.Children(1).Color = 'w';
colormap(jet)
set(gca,'ColorScale','log')

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by