Commands for a Specific Colorbar [closed]

谁说我不能喝 提交于 2020-01-26 04:52:14

问题


I am trying to write a script for this colorbar:

Where could I find such a script?


回答1:


Colorbars exist in Matlab (in fact, the command is colorbar). You can even change the color setting, e.g. by colormap winter (which will change both, the figure itself and the corresponding bar as its ledgend). You can also set the tick labels: colorbar('TickLabels',{'Extreme','Severe','Strong'}), but what you won't have are those crisp boundaries.

I feel that you are not looking for a true colorbar but rather a way to mimic a color bar to a plot, which is not suited for a Matlab-native colorbar (that are plots with a continously chaning color map/gradient). So what you are looking for is the function rectange to build your own colorbar

EDITED: As @LuisMendo noted, you can set your own colormap by specifying a ?x3 matrix with RGB values (which are in matlab in the range of [0,1], so you have to divide the "normal" values by 256). If you then place the ticks in the center of those values, you have everthiny you want + you can even name the colors as you like by setting the tick-labels

colormap([1 1 0; 0 1 1; 1 0 1])
colorbar('Ticks', [1/6 3/6 5/6], 'TickLabels',{'Extreme','Strong','None'})


来源:https://stackoverflow.com/questions/59761885/commands-for-a-specific-colorbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!