using a viridis colormap

293 ビュー (過去 30 日間)
Wissem
Wissem 2022 年 2 月 21 日
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.

採用された回答

Image Analyst
Image Analyst 2022 年 2 月 21 日
See attached demos where I show you how you can replace the default color order of plots and markers with some custom colormap of your own creation.
  1 件のコメント
Nidia Maldonado Carmona
Nidia Maldonado Carmona 2022 年 3 月 28 日
Thanks a lot for this! This has been really helpful!

サインインしてコメントする。

その他の回答 (2 件)

DGM
DGM 2022 年 2 月 21 日
編集済み: DGM 2022 年 2 月 21 日
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
Wissem 2022 年 2 月 21 日
Yes you are right : I totally missed this argument. However, I am still unable to use this command since the viridis function is not recognized despite the fact that it's added to my current path. I don't understand why it doesn't work : I am going to check again for the path directory.
Stephen23
Stephen23 2022 年 2 月 21 日
@Wissem-Eddine KHATLA: you can also place it into the current directory, which may be easier.

サインインしてコメントする。


Wissem
Wissem 2022 年 2 月 23 日
Thank you all for your help : I really got what I was looking for !
Thanks again !

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by