0

What are some examples of valid inputs for the c "color" argument of mplot3d's scatter?

i can input a single char basecolor such as 'r' and every datapoint is output in this color.

I can input an arrays of integers or floats, with the color output always being essentially a range of colors between yellow, green, and purple whether the range of my c values is 0< c <1 or 10< c <1000

If i try to input an array of hex values i receive the error

ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not ['0x1'...]

if i try to convert these integer/float values into indexes and then base colors, such that scatter is instead fed an array containing one of the "rgbcmykw" color strings such as ['r', 'g', 'b', 'b'...], i instead receive an exceptionally long Tkinter callback exception ending in:

TypeError: Cannot cast array data from dtype('float64') to dtype('<U32') according to the rule 'safe'

My script is pretty complicated and essentially involves interpreting PDB coordinate data, so it may be simpler if i do not get into the details.

My question is, what are some examples of values for c that will actually be interpreted without error, besides an array of floats? I have been looking at the tutorials all day but they are quite difficult to interpret without example code.

Kama
  • 39
  • 6

1 Answers1

0

Have you looked at https://matplotlib.org/stable/api/colors_api.html ?

'0x1' is not a valid color

'r' is a valid color, (1,0,0[,1.0]) is a valid color, '#f00' and #FF0000 are valid colors.

If you pass an array of colors, then the number of elements in your array must match the number of points.

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75
  • I have not seen this particular page before in my searches. It and you reply are tremendously helpful. I see now that it thakes RGB/RGBA in the form of decimals. This wasn't clear on the page for scatter and was a source of some confusion for me (i assumed it took them in int<255). I understand the hex issue now, thank you. I'm still not quite sure what the nature is of my single letter inputs being transformed to type=u32. I did check prior to asking that my color array was the correct length, as you sugggest. – Kama Feb 14 '21 at 17:43