scatter plot with data coord sized glyphs

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

scatter plot with data coord sized glyphs

Heiland, Randy
Hello,

Is it possible to specify scatter plot glyph sizes - specifically, circles and, e.g., radii, in data coords, rather than “marker size” of “points**2”?

thanks, Randy
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: scatter plot with data coord sized glyphs

matplotlib - users mailing list
Syrtis Major's gist at  https://gist.github.com/syrte/592a062c562cd2a98a83  seems to do what you want.  See this stackoverflow answer for an example of the circles function in action -
https://stackoverflow.com/questions/9081553/python-scatter-plot-size-and-style-of-the-marker/24567352#24567352

hth,
Scott

> On May 21, 2019, at 11:42 AM, Heiland, Randy <[hidden email]> wrote:
>
> Hello,
> Is it possible to specify scatter plot glyph sizes - specifically, circles and, e.g., radii, in data coords, rather than “marker size” of “points**2”?
> thanks, Randy
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: scatter plot with data coord sized glyphs

Heiland, Randy
Thanks Scott! That certainly gets me closer. One question/problem I still have is that it doesn’t seem to like RGB as colors, in spite of the docs. I’ve attached a simple  example.

Randy




> On May 21, 2019, at 12:35 PM, Scott Lasley <[hidden email]> wrote:
>
> Syrtis Major's gist at  https://gist.github.com/syrte/592a062c562cd2a98a83  seems to do what you want.  See this stackoverflow answer for an example of the circles function in action -
> https://stackoverflow.com/questions/9081553/python-scatter-plot-size-and-style-of-the-marker/24567352#24567352
>
> hth,
> Scott
>
>> On May 21, 2019, at 11:42 AM, Heiland, Randy <[hidden email]> wrote:
>>
>> Hello,
>> Is it possible to specify scatter plot glyph sizes - specifically, circles and, e.g., radii, in data coords, rather than “marker size” of “points**2”?
>> thanks, Randy

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

test_circ2.py (3K) Download Attachment
smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: scatter plot with data coord sized glyphs

matplotlib - users mailing list
From the docstring in circles - "Note that `c` should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. (If you insist, use `color` instead).   So a slight modification of your code seems to do what you want


fig = plt.figure(figsize=(5,3))
ax = fig.gca()
ax.set_aspect("equal")

xvals = np.array([0,100])
yvals = np.array([0,0])
rvals = np.array([30,10])

rgb = np.array([[255, 0, 0], [0, 255, 0]])

circles(xvals, yvals, s=rvals, color=rgb / 255.)  # use color instead of c and make  0. <= rgb <= 1.

plt.xlim(-30,110)
plt.ylim(-30,30)
plt.show()

Scott


> On May 21, 2019, at 2:08 PM, Heiland, Randy <[hidden email]> wrote:
>
> Thanks Scott! That certainly gets me closer. One question/problem I still have is that it doesn’t seem to like RGB as colors, in spite of the docs. I’ve attached a simple  example.
>
> Randy
>
> <test_circ2.py>
>
>> On May 21, 2019, at 12:35 PM, Scott Lasley <[hidden email]> wrote:
>>
>> Syrtis Major's gist at  https://gist.github.com/syrte/592a062c562cd2a98a83  seems to do what you want.  See this stackoverflow answer for an example of the circles function in action -
>> https://stackoverflow.com/questions/9081553/python-scatter-plot-size-and-style-of-the-marker/24567352#24567352
>>
>> hth,
>> Scott
>>
>>> On May 21, 2019, at 11:42 AM, Heiland, Randy <[hidden email]> wrote:
>>>
>>> Hello,
>>> Is it possible to specify scatter plot glyph sizes - specifically, circles and, e.g., radii, in data coords, rather than “marker size” of “points**2”?
>>> thanks, Randy
>

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: scatter plot with data coord sized glyphs

Heiland, Randy
Scott, thanks for the help once again! Yes, the results are exactly what I want, and seem to be quite fast for lots of circles.

Randy

> On May 21, 2019, at 2:39 PM, Scott Lasley <[hidden email]> wrote:
>
> From the docstring in circles - "Note that `c` should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. (If you insist, use `color` instead).   So a slight modification of your code seems to do what you want
>
>
> fig = plt.figure(figsize=(5,3))
> ax = fig.gca()
> ax.set_aspect("equal")
>
> xvals = np.array([0,100])
> yvals = np.array([0,0])
> rvals = np.array([30,10])
>
> rgb = np.array([[255, 0, 0], [0, 255, 0]])
>
> circles(xvals, yvals, s=rvals, color=rgb / 255.)  # use color instead of c and make  0. <= rgb <= 1.
>
> plt.xlim(-30,110)
> plt.ylim(-30,30)
> plt.show()
>
> Scott
>
>
>> On May 21, 2019, at 2:08 PM, Heiland, Randy <[hidden email]> wrote:
>>
>> Thanks Scott! That certainly gets me closer. One question/problem I still have is that it doesn’t seem to like RGB as colors, in spite of the docs. I’ve attached a simple  example.
>>
>> Randy
>>
>> <test_circ2.py>
>>
>>> On May 21, 2019, at 12:35 PM, Scott Lasley <[hidden email]> wrote:
>>>
>>> Syrtis Major's gist at  https://gist.github.com/syrte/592a062c562cd2a98a83  seems to do what you want.  See this stackoverflow answer for an example of the circles function in action -
>>> https://stackoverflow.com/questions/9081553/python-scatter-plot-size-and-style-of-the-marker/24567352#24567352
>>>
>>> hth,
>>> Scott
>>>
>>>> On May 21, 2019, at 11:42 AM, Heiland, Randy <[hidden email]> wrote:
>>>>
>>>> Hello,
>>>> Is it possible to specify scatter plot glyph sizes - specifically, circles and, e.g., radii, in data coords, rather than “marker size” of “points**2”?
>>>> thanks, Randy
>>
>

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

smime.p7s (5K) Download Attachment