Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colormap plot scatter points #2961

Closed
Alessi42 opened this issue Mar 14, 2024 · 2 comments
Closed

Colormap plot scatter points #2961

Alessi42 opened this issue Mar 14, 2024 · 2 comments

Comments

@Alessi42
Copy link

Feature request - Plot a scatter plot using a colormap rather than individually creating pens for each plot point.

This may be something that I have missed in the documentation however is it possible to plot a scatter with x,y,c where c is an array of colour values to be mapped using a colormap.

Currently I am achieving this by creating an array of pens and brushes which I then use for each spot.

brushes = [pg.mkBrush(QtGui.QColor(*c)) for c in color]
pens = [pg.mkPen(color=QtGui.QColor(*c), width=width) for c in edgecolors]

spi = pg.ScatterPlotItem(
      spots=[
                      {
                          "pos": (x_data[i], y_data[i]),
                          "pen": pens[i],
                          "brush": brushes[i],
                          "size": size[i],
                      }
                      for i in range(len(x_data))
                  ],
      ...

Thanks in advance.

@pijyoi
Copy link
Contributor

pijyoi commented Mar 16, 2024

You may be interested in #2960, where it is demonstrated that pre- creating QBrushes is the fast way.

@j9ac9k
Copy link
Member

j9ac9k commented Apr 29, 2024

Hi @Alessi42

I'm going to close out that issue, as I think the discussion pijyoi linked to is highly relevant to what you were seeking. The documentation could likely use some work to make this clearer, and a PR would be accepted to that effect. Let us know if you're still having troubles.

@j9ac9k j9ac9k closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants