【问题标题】:How to make the colormap correspond to the vertical coordinate?如何让colormap对应纵坐标?
【发布时间】:2020-04-23 03:36:09
【问题描述】:

考虑以下示例:

x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(1,10,length(x));
figure(); scatter(x,y,[],c);
colorbar

在本例中,数据点的颜色对应于水平坐标。相反,我希望颜色对应于垂直坐标。我怎样才能做到这一点?

【问题讨论】:

    标签: matlab matlab-figure colorbar scatter colormap


    【解决方案1】:

    你应该使用y作为颜色索引:

    scatter(x,y,[],y);
    

    结果:

    【讨论】:

    • @Abdullah 我很高兴听到这个消息!如果这个答案对你有帮助,请考虑accepting it
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    相关资源
    最近更新 更多