SciLab: RGB color plot, trying to color each mark with its respective color

跟風遠走 提交于 2019-12-11 18:08:09

问题


All,

I have made a 3d plot of some colors in the RGB color space. Currently the marks are all the same color. I would like each mark to be the color it represents in the space. So, a mark in the red corner of the plot should be red, etc...

The code I have so far is below.

Thanks for your help,

-Bill

// 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.

回答1:


As far as I know, you can only set the mark_foreground color of all the marks in a polyline to the same color. That is also confirmed by the documentation.

A fast solution would be to create a polyline for each marker and color it. A nicer solution would implementing a surface plot.

Working example

I created a working example based on your code, it is not pretty and has a lot of room for improvement. But it solves your direct question.

// 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


来源:https://stackoverflow.com/questions/19211789/scilab-rgb-color-plot-trying-to-color-each-mark-with-its-respective-color

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