ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 25 Aug 2019 17:52:24 +0200How to plot points of size less than 1?https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/I have a huge sequence L (say of length $n=10^6$) and I would like to plot all the points (i,L[i]) for i in range(n).
To do so, the following works.
points([(i,L[i]) for i in range(n)],size=1)
The problem is that `size=1` (for the points) is too large for a satisfactory plotting.
But if $r$ is a fixed float with $0< r <1$, then
points([(i,L[i]) for i in range(n)],size=r)
is interpreted as
points([(i,L[i]) for i in range(n)],size=0)
which is an empty plotting (so not working).
**Question**: How to rewrite the second command line above to really plot points of `size=r`?Fri, 23 Aug 2019 08:09:04 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/Answer by Emmanuel Charpentier for <p>I have a huge sequence L (say of length $n=10^6$) and I would like to plot all the points (i,L[i]) for i in range(n). <br>
To do so, the following works.</p>
<pre><code>points([(i,L[i]) for i in range(n)],size=1)
</code></pre>
<p>The problem is that <code>size=1</code> (for the points) is too large for a satisfactory plotting. </p>
<p>But if $r$ is a fixed float with $0< r <1$, then</p>
<pre><code>points([(i,L[i]) for i in range(n)],size=r)
</code></pre>
<p>is interpreted as </p>
<pre><code>points([(i,L[i]) for i in range(n)],size=0)
</code></pre>
<p>which is an empty plotting (so not working).</p>
<p><strong>Question</strong>: How to rewrite the second command line above to really plot points of <code>size=r</code>?</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?answer=47574#post-id-47574The `size` of a point is in *physical* units (no relation to the numbers you're trying to represent). From `point2d?`:
* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.
If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.
But I probably wouldn't be able to see your points (literally...).Fri, 23 Aug 2019 10:13:26 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?answer=47574#post-id-47574Comment by Sébastien Palcoux for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47576#post-id-47576To better understand my problem, see the plottings I made and put in the following link:
[https://mathoverflow.net/q/338415/34538](https://mathoverflow.net/q/338415/34538)
The first one is a zoom of the second, but see how the shape of the first is lost in the second because the point size is too large...Fri, 23 Aug 2019 10:52:55 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47576#post-id-47576Comment by Emmanuel Charpentier for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47578#post-id-47578The "shape" ou perceive on the first plot may be artefactual, due to points not being visible (i. e. too small/infrequent to be plotted).
Try to plot your "large" region on a large (bedsheet- or even wheat-field-sized) surface and scan-pan-zoom on it. This may reveal points not plotted or perceived when zoomed back to a 4"x4" screen (resolution about 96 DPI, IIRC).Fri, 23 Aug 2019 12:32:44 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47578#post-id-47578Comment by Sébastien Palcoux for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47580#post-id-47580My word "zoom" was not correct. These two plottings were done independently, what I mean is that the first graph is a subset of the second.Fri, 23 Aug 2019 12:52:18 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47580#post-id-47580Comment by Emmanuel Charpentier for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47581#post-id-47581Better idea: try to estimate the *density* of your points, and plot that (either as a 3D plot or via $\alpha$. This should (partially) avoid the difficulties created by the rendering software...
`R` has some nice packages for multidimensional kernel estimation.Fri, 23 Aug 2019 12:54:57 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47581#post-id-47581Comment by Emmanuel Charpentier for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47582#post-id-47582> My word "zoom" was not correct. This two plottings were done independently, what I mean is that the first graph is a subset of the second.
That's not the problem. The problem is that the rendering software *may* suppress representation of elements too small to be perceptible, and that your eyes *will* omit them. You're fighting both physics and physiology...Fri, 23 Aug 2019 12:57:43 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47582#post-id-47582Comment by Emmanuel Charpentier for <p>The <code>size</code> of a point is in <em>physical</em> units (no relation to the numbers you're trying to represent). From <code>point2d?</code>:</p>
<pre><code>* "size" -- How big the point is (i.e., area in points^2=(1/72
inch)^2).
</code></pre>
<p>A 1pt point is already really small (practically invisible), even in a not-so-large figure (4in x 4in). I don't know it smaller points can physically be rendered, at least on screens (maybe on high-resolution printers.</p>
<p>If necessary, use a large image size and scale the resulting figure via, say, Imagemagick.</p>
<p>But I probably wouldn't be able to see your points (literally...).</p>
https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47586#post-id-47586**Further comment :** computing and plotting the *density* of points pays off : the "empty" regions are not empty, but simply *sparse*.
Implementation notes:
- The `bkde2D` function in the R package `KernSmooth` is reasonaby fast (about 0.7 seconds to get a 500x500 density grid).
- Passing large vectors to R is ***horribly*** slow.
- Using temporary ASCII files is much faster for, say, vectors larger than 5000.
- OTOH, passing back large R objects to Sage is tolerably fast.
Therefore, the "best" strategy is toi define an R wrapper reading data from a temporary file and sending back the result to a Sage variable.Sun, 25 Aug 2019 17:52:24 +0200https://ask.sagemath.org/question/47573/how-to-plot-points-of-size-less-than-1/?comment=47586#post-id-47586