【问题标题】:SciLab: RGB color plot, trying to color each mark with its respective colorSciLab:RGB 颜色图,尝试用各自的颜色为每个标记着色
【发布时间】:2013-10-06 17:36:15
【问题描述】:

全部,

我在 RGB 颜色空间中制作了一些颜色的 3d 图。目前这些标记都是相同的颜色。我希望每个标记都是它在空间中代表的颜色。所以,情节的红色角落的标记应该是红色的,等等......

我目前的代码如下。

感谢您的帮助,

-比尔

// RGB color data for a few shades of pink and red

r = [1, 1, 1, 1, 0.8588235294117647, 0.7803921568627451, 1, 0.9803921568627451, 0.9137254901960784, 0.9411764705882353]';

g = [0.7529411764705882, 0.7137254901960785, 0.4117647058823529, 0.07843137254901961, 0.4392156862745098, 0.08235294117647059, 0.6274509803921569, 0.5019607843137255, 0.5882352941176471, 0.5019607843137255]';

b = [0.796078431372549, 0.7568627450980392, 0.7058823529411765, 0.5764705882352941, 0.5764705882352941, 0.5215686274509804, 0.4784313725490196, 0.4470588235294118, 0.4784313725490196, 0.5019607843137255]';

// Draw 3D graph from R G B vectors

param3d(r,g,b,35,45,"Red@Green@Blue",[2,4]);

title("Some Shades of Pink and Red");


// Set marks to ball style

p=get("hdl");

p.mark_style = 9;



// Turn lines off so we just have points

e = gce();

e.line_mode="off";

e.mark_mode="on";


// Set color map to our RGB values

cmap=[r g b];


// Put some code here to color each mark with its respective color
// I have no idea what to do at this point.

【问题讨论】:

    标签: plot scilab


    【解决方案1】:

    据我所知,您只能将折线中所有标记的mark_foreground颜色设置为相同的颜色。 the documentation.也证实了这一点

    一个快速的解决方案是为每个标记创建一条折线并为其着色。更好的解决方案是实现曲面图。

    工作示例

    我根据您的代码创建了一个工作示例,它并不漂亮,还有很大的改进空间。但它解决了你的直接问题。

    // RGB color data for a few shades of pink and red
    
    r = [1, 1, 1, 1, 0.8588235294117647, 0.7803921568627451, 1, 0.9803921568627451, 0.9137254901960784, 0.9411764705882353]';
    
    g = [0.7529411764705882, 0.7137254901960785, 0.4117647058823529, 0.07843137254901961, 0.4392156862745098, 0.08235294117647059, 0.6274509803921569, 0.5019607843137255, 0.5882352941176471, 0.5019607843137255]';
    
    b = [0.796078431372549, 0.7568627450980392, 0.7058823529411765, 0.5764705882352941, 0.5764705882352941, 0.5215686274509804, 0.4784313725490196, 0.4470588235294118, 0.4784313725490196, 0.5019607843137255]';
    
    // Draw 3D graph from R G B vectors
    
    for i=1:length(r)
        param3d( r(i), g(i), b(i), 35,45,"Red@Green@Blue",[2,4]);
    
        if( i == 1 )
            title("Some Shades of Pink and Red");
    
            // Set color map to our RGB values
            cmap=[r g b];
    
            // Put some code here to color each mark with its respective color 
    
            //assign the colormap to the current figure
            f=gcf(); 
            f.color_map=cmap;
        end
    
        p=get("hdl");
    
        p.mark_style = 9;
    
        // Turn lines off so we just have points
        e = gce();
        e.line_mode="off";
        e.mark_mode="on";
    
        // Assign the mark color
        e.mark_foreground= i ;
    end
    

    【讨论】:

    • 哇,您的解决方案正是我所需要的。我添加了 e.mark_background= i ;到代码,它为背景着色就好了。现在我可以看到点之间的关系以及与立方体的关系。我不确定表面图会达到同样的效果,但如果不是太麻烦的话,我想看看它。问候... -比尔
    猜你喜欢
    • 2017-12-02
    • 2020-01-23
    • 2022-01-24
    • 2023-03-30
    • 2013-05-22
    • 2018-10-12
    • 1970-01-01
    • 1970-01-01
    • 2020-08-01
    相关资源
    最近更新 更多