<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, colour and 2D point-plots</title>
    <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Wed, 10 Jun 2026 17:39:44 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 17:39:44 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, colour and 2D point-plots</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, colour and 2D point-plots</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots</link>
    </image>
    <item>
      <title>RGB(xy[i, 2], 0., 0.),</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots?ref=Feed:MaplePrimes:colour and 2D point-plots:Comments#comment135275</link>
      <itunes:summary>&lt;p&gt;On my computer is faster the following command to: "Maple 15"&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;plots:-pointplot(xy, color = [seq(RGB(xy[i, 2], 0., 0.), i = 1 .. N)], symbolsize = 4)&lt;/p&gt;
&lt;p&gt;&amp;gt; time[real]()-str;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.000&lt;br&gt;&amp;gt; kernelopts(bytesalloc);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 37283156&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;subsindets(p, specfunc(anything, COLOUR), proc (z) options operator, arrow; ('COLOUR')('RGB', c) end proc)&lt;/p&gt;
&lt;p&gt;&amp;gt; time[real]()-str;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.516&lt;br&gt;&amp;gt; kernelopts(bytesalloc);&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, colour and 2D point-plots</description>
      <guid>135275</guid>
      <pubDate>Wed, 20 Jun 2012 01:02:23 Z</pubDate>
      <itunes:author>herclau</itunes:author>
      <author>herclau</author>
    </item>
    <item>
      <title>evalhf or Compiled</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots?ref=Feed:MaplePrimes:colour and 2D point-plots:Comments#comment135277</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots#comment135275"&gt;@herclau&lt;/a&gt; That doesn't prove much, since the original does not appear to be optimized for speed. Using a float[8] Array the procedure which populates the color values (inplace) could be Compiled or run under evalhf, after which it would be &lt;em&gt;much&lt;/em&gt; faster.&lt;/p&gt;
&lt;p&gt;Under evalhf, populating float[8] Array c inplace with a procedure, I see 3.4 times faster than with your approach.&lt;/p&gt;
&lt;p&gt;Also, the original is not optimized for memory either. For N=25000 it can actually be done with only 3.3 MB allocated.&lt;/p&gt;
&lt;pre&gt;restart:
N:=25000:

xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):
str:=time[real]():
f:=proc(A::Array(datatype=float[8],order=C_order),
        xy::Matrix(datatype=float[8]), n)
 local i;
 for i from 1 to n*3 do
  A[i]:=`if`(irem(i,3)=1,xy[(i+2.0)/3.0,2],0);
 end do:
 NULL:
end proc:

p:=plots:-pointplot(xy,color=red,symbolsize=4):

c:=Array(1..N*3, datatype=float[8],order=C_order):
evalhf(f(c,xy,N)):
subsindets(p,specfunc(anything,COLOUR),z-&amp;gt;'COLOUR'('RGB',c));

                           PLOT(..)  (actually displayed in my Maple 15)

time[real]()-str;

                             0.227

kernelopts(bytesalloc);

                            3276200
&lt;/pre&gt;
&lt;p&gt;whereas&lt;/p&gt;
&lt;pre&gt;restart:
N:=25000:

xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):

str:=time[real]():

plots:-pointplot(xy,
                    color=[seq(RGB(xy[i, 2], 0., 0.), i = 1 .. N)],
                    symbolsize=4);


                           PLOT(..)  (actually displayed in my Maple 15)
time[real]()-str;

                              0.882

kernelopts(bytesalloc);
                            42721648
&lt;/pre&gt;</itunes:summary>
      <description>The latest comments added to the Post, colour and 2D point-plots</description>
      <guid>135277</guid>
      <pubDate>Wed, 20 Jun 2012 01:15:50 Z</pubDate>
      <itunes:author>pagan</itunes:author>
      <author>pagan</author>
    </item>
    <item>
      <title>optimizing</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots?ref=Feed:MaplePrimes:colour and 2D point-plots:Comments#comment135279</link>
      <itunes:summary>&lt;p&gt;To be honest I did not give optimizing this as much consideration as I might have.&lt;/p&gt;
&lt;p&gt;Partly that is because it should be utterly clear by this date in time that a float[8] Array will soundly beat a list (or sequence) of floats at these sizes, both in terms of speed and memory.&lt;/p&gt;
&lt;p&gt;But there is so much more the the float[8] Array brings with it. It allows the color data to be held in a truly mutable data structure, which means it can be used and re-used with minimal penalty of memory managment. (...animation comes to mind.) There are a wealth of Library and kernel routines which have themselves been optimized for handling float[8]. And it will always take proportionally less memory allocation. (The only single thing that could take less memory while offering the color depth is float[4], and there are less routines optimized speedwise for that.)&lt;/p&gt;
&lt;p&gt;Let's compare the two previous suggestions (both faster than my original) with one more faster way, which is to use ArrayTools:-Copy.&lt;/p&gt;
&lt;p&gt;I have suppressed display of the plot, in the timing runs below, because I found that repeatedly rerunning the whole set of code would produce somewhat random timings. In general, however, I thought that I saw timings like what follows below, but on average with a constant addition of the time it takes for the GUI to display the plot. Hence, timings are without the plots being rendered on the worksheet.&amp;nbsp; (32bit Windows below. In 64bit the memory size of Herclau's method rises to abotu 47.0 MB, and of the other to about 3.3 MB.)&lt;/p&gt;
&lt;pre&gt;restart:
N:=25000:
xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):
str:=time[real]():
plots:-pointplot(xy,
                    color=[seq(RGB(xy[i, 2], 0., 0.), i = 1 .. N)],
                    symbolsize=4):
time[real]()-str;

                             0.327

kernelopts(bytesalloc);

                            18150148

restart:
N:=25000:
xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):
str:=time[real]():
f:=proc(A::Array(datatype=float[8],order=C_order),
        xy::Matrix(datatype=float[8]), n)
 local i;
 for i from 1 to n*3 do
  A[i]:=`if`(irem(i,3)=1,xy[(i+2.0)/3.0,2],0);
 end do:
 NULL:
end proc:
p:=plots:-pointplot(xy,color=red,symbolsize=4):
c:=Array(1..N*3, datatype=float[8],order=C_order):
evalhf(f(c,xy,N)):
subsindets(p,specfunc(anything,COLOUR),z-&amp;gt;'COLOUR'('RGB',c)):
time[real]()-str;

                             0.046

kernelopts(bytesalloc);

                            2293340

restart:
N:=25000:
xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):
str:=time[real]():
p:=plots:-pointplot(xy,color=red,symbolsize=4):
c:=Array(1..N*3, datatype=float[8],order=C_order):
ArrayTools:-Copy(N,xy,N,1,c,0,3);
subsindets(p,specfunc(anything,COLOUR),z-&amp;gt;'COLOUR'('RGB',c)):
time[real]()-str;

                             0.016

kernelopts(bytesalloc);

                            2293340
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, colour and 2D point-plots</description>
      <guid>135279</guid>
      <pubDate>Wed, 20 Jun 2012 05:19:55 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>the choice of color</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots?ref=Feed:MaplePrimes:colour and 2D point-plots:Comments#comment135301</link>
      <itunes:summary>&lt;p&gt;Someone asked me what makes the final color red, since changing the color=red to color=green in the line of code which creates the initial plot (and assigns it to `p`) does not affect the final result of a point-plot with a red color gradient.&lt;/p&gt;
&lt;p&gt;The color=red in the initial call,&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; p:=plots:-pointplot(xy,color=red,symbolsize=4):&lt;br&gt;&lt;br&gt;is only there so that the PLOT structure has a COLOR section which can be replaced. I probably ought to have chosen some other color and mentioned that the particular choice -- at this stage -- is irrelevent as far as the goal goes.&lt;br&gt;&lt;br&gt;The actual coloring of the result was determined by the originally posted bit of code,&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; (i)-&amp;gt;`if`(irem(i,3)=1,xy[(i+2)/3,2],0)&lt;br&gt;&lt;br&gt;in the Array constructor call which creates Array `c`. And n the ArrayTools:-Copy example, the final color was determined by choosing a stride which only copied every third entry, starting with the first (ie. the "red" parts of each triple).&lt;br&gt;&lt;br&gt;This post is just an exposition, to show that the float[8] Array can be used to set a coloring scheme. It allows for all kinds of schemes, where rgb or hue can change gradually in any direction, or even along a conceptualized curve in space.&lt;br&gt;&lt;br&gt;If someone were to turn the process into a robust procedure, which could be applied after the fact to any pointplot PLOT strucure, then it would test for the presence of a COLOR section. If it already existed then it would be replaced, and if it did not already exist then it would get added.&lt;/p&gt;
&lt;p&gt;In much older Maple releases the location data itself of a 2D plot could not be supplied as&amp;nbsp; float[8] rtables. Then, for some release(s), such rtables (eg. Matrix, Array) were used internally but not acceptable as arguments to the plot commands. That's around the time frame at which Robert Israel noticed that a PLOT/PLOT3D structure could be manually formed with such rtables, and his fast plotters in his Maple Advisor database ensued. And in recent Maple versions many plot commands have been changed to accept their data argument as such float[8] rtables. But that's just the point location data. It's a natural progression that the color-specification data -- which has become float[8] internally -- would finally be acceptable as input as well. That's my opinion, anyway.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, colour and 2D point-plots</description>
      <guid>135301</guid>
      <pubDate>Wed, 20 Jun 2012 23:38:10 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>simple syntax</title>
      <link>http://www.mapleprimes.com/posts/135253-Colour-And-2D-Pointplots?ref=Feed:MaplePrimes:colour and 2D point-plots:Comments#comment200702</link>
      <itunes:summary>&lt;p&gt;In Maple 18 a vertical color gradient can be applied directly and efficienctly in the plotting call, using the &lt;a href="http://www.maplesoft.com/support/help/Maple/view.aspx?path=plot/colorscheme"&gt;colorscheme&lt;/a&gt;&amp;nbsp;option.&lt;/p&gt;
&lt;p&gt;Eg,&lt;/p&gt;
&lt;pre&gt;restart:
N:=25000:
xy:=LinearAlgebra:-RandomMatrix(N,2,generator=0.0..1.0,
                                outputoptions=[datatype=float[8]]):

st,str:=time(),time[real]():

P:=plots:-pointplot(xy, colorscheme=["zgradient",[black,red]],
                    symbolsize=4):

time()-st,time[real]()-str;

                          0.090, 0.093

kernelopts(version);

    Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, colour and 2D point-plots</description>
      <guid>200702</guid>
      <pubDate>Thu, 21 May 2015 17:23:47 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>