question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting pointColors with custom colormaps

See original GitHub issue

The results of the mesh_coloring.py example does not produce a colored man in the middle as would be expected, see image: selection_001

What I’d like to do is setting the colors per point of an polydata object based on my own colormap, so that I can define the scaling from min to max.

# myarr is a numpy float32 1D array with e.g. min=10, max = 20000
from vtkplotter import colorMap
r, g, b = colorMap(... name='jet', vmin=myarr.min(), vmax=myarr.max())

and somehow pass this to an actor:

man1.pointColors(myarr alpha=0.5, cmap=MyColormapAbove)

A working example would be very helpful.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
marcomusycommented, Dec 5, 2019

sorry that’s not very clear to me, do you want to set colors to cell based on edge length, or color the edges? Is the snippet already the solution? (Indeed it is a very clever one to colorize lines!)

from vtkplotter import *
import numpy as np

sph = Sphere().cutWithPlane()

sPoints = np.zeros([sph.N(),3]) + [0.75, 0, 0.1]
ePoints = sph.coordinates()

rays = Lines(sPoints, ePoints)
rays.cellColors(mag(sPoints-ePoints), cmap="spring")
rays.show(bg="w", axes=2)

image

1reaction
unidesignercommented, Jan 23, 2019

Indeed, there was an old version hiding which got imported first. Your example works now and I can control the colormap with the vmin/vmax as I wanted. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting pointColors with custom colormaps · Issue #10 - GitHub
What I'd like to do is setting the colors per point of an polydata object based on my own colormap, so that I...
Read more >
Simple steps to create custom colormaps in Python
So today I am going to show you how I usually resolve this problem by creating my custom colormap based on any image....
Read more >
GGPlot Colors Best Tricks You Will Love - Datanovia
This article presents multiple great solutions you should know for changing ggplot colors. Many predefined color palettes are also provided.
Read more >
Colors (ggplot2) - Cookbook for R
Sample data; Simple color assignment; Mapping variable values to colors; A colorblind-friendly palette; Color selection; Setting luminance and saturation ...
Read more >
Creating Colormaps in Matplotlib
This can be done using the class ListedColormap and a Nx4 numpy array of values between 0 and 1 to represent the RGBA...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found