How to generate random RGB values through which black text is reliably visible?

I’d like to constrain the randomly coloured nodes in my graphplot to light colours through which black font text is reliably visible. The functions in Random do not operate well with RGB since math is not permitted. How to approach this issue?

Do you actually want random colors? For graphics, it’s often more important that your colors are distinguishable from one another. Colors.jl offers distinguishable_colors for that purpose: Colormaps and Colorscales · Colors

Well, I guess I was looking for some approach that is a bit more intuitive than the distinguishable colors route. Yes, laziness on my part. Generating some random numbers in a specific range is quickly checkable, which is not as easy via the distinguishable route.

However your suggestion encouraged me to go back to distinguishable colours again with renewed vigor, and I now, after some effort seem to have fallen into a set of values that almost does what I am looking for. I wish I could say it was solid reasoning and understanding that led me to this point, but my current settings are giving me node colours that permit text to show fairly clearly.

One oddity that results from my muddled appreciation of what the automated routine is trying to do is that one of the nodes appears completely white on every graphplot I produce. If there are no edges attached to that node or text to signify its presence the viewer would not know it was there on a white background which is what is used on a browser viewing of a png. A rand() + RGB() approach would enable me to quickly eliminate that possibility. Perhaps if it is possible to put a coloured ring around all the nodes then white might be acceptable but that is only half a solution.

RGB is a poor color model for this. You’ll find it easier to pick values with the HSL color model, then converting back to RGB.

Perhaps try the dropseed=true option?