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.Thu, 20 May 2021 10:24:56 +0200Plot points of different sizeshttps://ask.sagemath.org/question/57173/plot-points-of-different-sizes/Say I have a map M:
[0,1] -> .3
[1,2] -> 1.1
[-3,-3] -> .6
etc.
I want to make a scatter plot where the point at P has size M[P]. How do I do this? Presumably I use the point2d object, which takes a size parameter.Thu, 20 May 2021 00:32:57 +0200https://ask.sagemath.org/question/57173/plot-points-of-different-sizes/Comment by slelievre for <p>Say I have a map M:</p>
<p>[0,1] -> .3</p>
<p>[1,2] -> 1.1</p>
<p>[-3,-3] -> .6</p>
<p>etc.</p>
<p>I want to make a scatter plot where the point at P has size M[P]. How do I do this? Presumably I use the point2d object, which takes a size parameter.</p>
https://ask.sagemath.org/question/57173/plot-points-of-different-sizes/?comment=57177#post-id-57177Did you define `M` as a function? as a dictionary? Please provide the code you wrote so far.Thu, 20 May 2021 10:16:06 +0200https://ask.sagemath.org/question/57173/plot-points-of-different-sizes/?comment=57177#post-id-57177Answer by slelievre for <p>Say I have a map M:</p>
<p>[0,1] -> .3</p>
<p>[1,2] -> 1.1</p>
<p>[-3,-3] -> .6</p>
<p>etc.</p>
<p>I want to make a scatter plot where the point at P has size M[P]. How do I do this? Presumably I use the point2d object, which takes a size parameter.</p>
https://ask.sagemath.org/question/57173/plot-points-of-different-sizes/?answer=57178#post-id-57178Using `point2d` is indeed the right idea.
We will need to
- scale the values of `M` to turn them into reasonable
point sizes for `point2d`.
- use a separate `point2d` command for each point size
Here is an example using the values in the question:
Define `M` as a dictionary:
sage: M = {(0, 1): 0.3, (1, 2): 1.1, (-3, -3): 0.6}
Plot:
sage: sum(point2d([p], size=100*s) for p, s in M.items())
![Scatter plot with different point sizes](/upfiles/16214991181243265.png)Thu, 20 May 2021 10:24:56 +0200https://ask.sagemath.org/question/57173/plot-points-of-different-sizes/?answer=57178#post-id-57178