using a viridis colormap
이전 댓글 표시
Hello everyone,
I would like to know how is it possible to use properly a viridis colormap in order to draw scatter figures. For instance, i have this figure to plot :
figure(2)
plot(x1,y1,'^r','MarkerSize',8,'MarkerFaceColor','r')
% plot(x1,y1,'^r','MarkerSize',8,'MarkerFaceColor',viridis(5))
xlabel('F_{vis}')
ylabel('F_{flambement}','FontSize',13)
But I don't know how to use this "alternative" colormap since I am not familiar with this function in this case.
Could someone help please ?
Thank you in advance.
Sincerely.
채택된 답변
추가 답변 (2개)
Use scatter() instead of plot(). The behavior of viridis() is otherwise the same as the built-in functions like jet().
N = 20;
x1 = randn(N,1);
y1 = randn(N,1);
scatter(x1,y1,50,viridis(N),'filled','^')
댓글 수: 5
Wissem
2022년 2월 21일
"What's wrong with that ?"
The SCATTER documentation shows that if the 1st and 2nd arguments are X and Y values then the 3rd argument must be the marker size (which you did not provide). The 4th argument is the marker color (not 3rd like you tried).

Also VIRIDIS is not inbuilt. Did you download VIRIDIS from here:
https://www.mathworks.com/matlabcentral/fileexchange/62729-matplotlib-perceptually-uniform-colormaps
and unzip the ZIP file onto your MATLAB path, before trying to use it?
DGM
2022년 2월 21일
As Stephen says, you're missing the marker size specification in the call to scatter().
Wissem
2022년 2월 21일
Stephen23
2022년 2월 21일
@Wissem-Eddine KHATLA: you can also place it into the current directory, which may be easier.
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

