Octave为每个点绘制不同的颜色

时间:2015-06-12 20:43:07

标签: plot octave

我遇到了一个具体的问题。首先我使用的是八度音阶。我有一个数据集,其中每一行都具有以下格式:

   <xsl:param name="StyleNode" />
<xsl:if test="$Node/RelatedProducts_Expanded != ''">
  <div class="relatedProducts siteBounds">
    <div class="wrapper">
      <h5>Related Products</h5>
      <div class="slider sliderRelatedProducts">
        <div class="leftarrow" >
          <i class="fa fa-angle-double-left">&#160;</i>
        </div>
        <div class="rightarrow" >
          <i class="fa fa-angle-double-right">&#160;</i>
        </div>
        <div class="clipper">
          <ul>
            <xsl:for-each select="$Node/RelatedProducts_Expanded/Option">
              <li>
                <div class="productWrapper">
                  <xsl:if test="./ImageFile != ''">
                    <a href="{./@Value}" class="image">
                      <img>
                        <xsl:attribute name="src">
                          <xsl:value-of select="./ImageFile" disable-output-escaping="yes" />
                        </xsl:attribute>
                        <xsl:attribute name="alt">
                          <xsl:value-of select="./DisplayName"/>
                        </xsl:attribute>
                      </img>
                    </a>
                  </xsl:if>
                  <h4>
                    <a href="{./@Value}">
                      <xsl:value-of select="./DisplayName" disable-output-escaping="yes" />
                    </a>
                  </h4>
                  <p class="teaser">
                    <xsl:value-of select="./ShortDescription"/>
                  </p>
                  <p class="linkText">
                    <a href="{./@Value}">
                      Read more
                    </a>
                  </p>
                </div>
              </li>
            </xsl:for-each>
          </ul>
        </div>
      </div>
    </div>
  </div>

数据集的长度是无关紧要的,但假设它是10.我希望能够在每个具有特定颜色索引颜色的点上绘制3d图。当然我知道我可以使用for循环并单独添加每个点,但我发现很难相信使用向量还没有某种方法可以做到这一点。

到目前为止,我已经尝试过:

function slider(wrapper){
$(wrapper + ' ul').each(function () {
    // this part unrelated to resize
    var numItems = $(wrapper + ' li').length; // number of items in slider
    var imgw = $(wrapper + ' li').width(); // width of image in li
    var ml = parseInt($(wrapper + ' li:first-child').css('marginLeft').replace('px','')); //left margin
    var mr = parseInt($(wrapper + ' li:first-child').css('marginRight').replace('px','')); //right margin
    var m = (ml+mr); //total margin
    var itemWidth = (imgw+m); // img width + margin
    var ulWidth = (itemWidth*numItems); // width for ul
    $(wrapper + ' ul').width(ulWidth); // apply ul width
    var $list = $(wrapper + ' .clipper ul');
    var $prev = $(wrapper + ' .leftarrow').css({ display:'block'}); // previous
        var $next = $(wrapper + ' .rightarrow').css({ display:'block'}); // next
        var $clip = $(wrapper + ' .clipper');
        $prev.addClass("disabled");

        if ($(this).width() < $clip.width()){
            $next.addClass("disabled");
            $prev.addClass("disabled");
        } else {
            $next.click(function () { 
                var pos = $list.position();
                var scroll = itemWidth * -1;
                var scrollStop = ((numItems * itemWidth) - $clip.width()) * -1;
                if ((pos.left > scrollStop) && (pos.left + scroll > scrollStop))
                    $list.animate({ left: "+=" + scroll + "px" }, "normal");
                else if (pos.left + scroll <= scrollStop) {
                    $list.animate({ left: scrollStop + "px" }, "normal");
                    $next.addClass("disabled");
                    $prev.removeClass("disabled");
                }
                $prev.removeClass("disabled");

            });

           $prev.click(function () {
                var pos = $list.position();
                var scroll = itemWidth;
                var scrollStop = 0;
                if ((pos.left < scrollStop) && (pos.left + scroll < scrollStop))
                    $list.animate({ left: "+=" + scroll + "px" }, "normal");
                else if (pos.left + scroll >= scrollStop) {
                    $list.animate({ left: scrollStop + "px" }, "normal");
                    $prev.addClass("disabled");
                    $next.removeClass("disabled");
                }
                $next.removeClass("disabled");
            });
        }

});

任何想法,如果可以为我的问题做单线程?

1 个答案:

答案 0 :(得分:0)

使用scatter3

N_colors = 64;
colormap(cool(N_colors));
# point positions (your data(:, 1:3))
[x, y, z] = peaks (20);
# these are the color indexes in the colormap (your data(:, 4))
c_index = fix(rand(size(x)) * N_colors);
marker_size = 8;

scatter3(x(:), y(:), z(:), marker_size, c_index(:))

enter image description here