How to create color map?

조회 수: 4 (최근 30일)
Ilkin Abdullayev
Ilkin Abdullayev 2020년 6월 5일
댓글: Adam Danz 2020년 6월 12일
Hello everybody,
I plot a bargraph by using 2x500, and I need to create a colormap. However it is a bit strange colormap so I need code that, for example, all the values between 15-20 will be blue, all the values between 20-25 will be red and so on. I have never worked with bar colormap and especially with this kind of code. If someone can help I would be very glad.
Thanks in advance.
  댓글 수: 6
Ilkin Abdullayev
Ilkin Abdullayev 2020년 6월 7일
Yes, I will have thousands bar graph even more since 7×10000 is only a little part of my full data. Thank you for the link I will try to get a result otherwise I will let you know.
Ilkin Abdullayev
Ilkin Abdullayev 2020년 6월 8일
Hello, I tried stacked bar graph and the resul is good. I have uploaded 2 bar but I will have thousand. So what I need now, is to create a new colormap where I need to specify that for example the number between 15-20 is blue. Then when I plot whereever I will have a value between this range it will trun blue. Not one full column. I mean for example in the picture the second part of both bar from top is red. Then if this red section has a value betwen 15-20 the color will be blue. I have very big data that is why I need a colormap that I can use for all. It is not feasible to change the colors one by one.
Hopefully I explained clearly.

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

채택된 답변

Adam Danz
Adam Danz 2020년 6월 8일
편집: Adam Danz 2020년 6월 10일
Use a stacked bar graph by entering an nxm matrix which will produce n bars each with m segments.
h = bar(rand(20,40), 'stacked'); % 20 bars, 40 segments each
Change the color of bars 15-20 to blue.
set(h(15:20), 'FaceColor', 'b')
  댓글 수: 2
Ilkin Abdullayev
Ilkin Abdullayev 2020년 6월 12일
Hello, Sorry for late answer. I found some other way with square scatter but also tried this one and it works.
Just to let to know other that How I got my results:
x=data.a;
y=data.b;
c=deneme13280.Load;
colormap(mymap)
scatter(x, y, [70], c, 's','filled')
xlabel('A');
ylabel('B');
And the reasons to use scatter was that, I need all the pieces of one bar must have same size then I used scatter instead of using my main data in x axis I used it as a color identificator which is c here.
Adam Danz
Adam Danz 2020년 6월 12일
And the result is a bar graph?

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by