0

I'm trying to do something similar as the image I uploaded with python and pyplot. I need a scatter plot with different opacity spread for each dot. As you can see, the first one have less opacity in the border, last last one have 100% opacity.

Is it possible with pyplot and python? Thanks

different images spread

Steve
  • 406
  • 3
  • 11
  • can this help? https://stackoverflow.com/questions/30108372/how-to-make-matplotlib-scatterplots-transparent-as-a-group – antoine Jan 11 '21 at 08:34
  • you can set `alpha` (0-1) to control opacity. – antoine Jan 11 '21 at 08:35
  • 1
    @antonine alpha regulate only the general opacity, not like a spread. Am I right? – Steve Jan 11 '21 at 08:48
  • yes, it does not render as gaussian like pattern. Maybe you can use in addition parameter `s` to change size, but this will not render like your image. Maybe some one can have other idea. – antoine Jan 11 '21 at 08:57
  • Does this answer your question? [How to plot blurred points in Matplotlib](https://stackoverflow.com/questions/25022661/how-to-plot-blurred-points-in-matplotlib) – Mr. T Jan 11 '21 at 13:20

1 Answers1

0

I would suggest using a different toolbox to add blur to images but in theory it would be possible using matplotlib. For example

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
def add_blur(center = (0, 0), n = 10, radius = .5, blur = 1.1):
    artists = [plt.Circle(center, radius = radius)]
    for i in range(0, n):
        r = (n - i)/ (n) * ( blur * radius)
        alpha = i/(n)
        a = plt.Circle(center, radius = r, alpha = alpha)
        artists.append(a)
    return artists

ns = [200, 1]
centers = [(-1, 0), (1, 0)]
for center, n in zip(centers, ns):
    artists = add_blur(center = center, n = n)
    [ax.add_artist(a) for a in artists]
    
ax.axis('equal')
ax.set(xlim = (-2, 2), ylim = (-2 ,2),
      )
fig.show()

Gives:

enter image description here

cvanelteren
  • 1,633
  • 9
  • 16