Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.4K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

VertexColors not working with ListPlot3D

POSTED BY: Gary Lawson
4 Replies

I'm not sure where your example goes wrong here is the correct way:

SetDirectory[NotebookDirectory[]];
data=Import["data.csv"];
colors=Import["color.csv"];
colors=Map[ToExpression,colors,{2}];
colors//Flatten//Tally
Dimensions/@{colors,data}

Note that I Map ToExpression over level 2, rather than level 1 as you did.

ListPlot3D[data, VertexColors -> {colors}]

VertexColors needs an extra {} for some reason I'm not sure of, probably if you have multiple plots, to distinguish each vertexcolors for each plot...

POSTED BY: Sander Huisman

Sander, thanks for your reply:

Yes I am able to run examples, such as the one I hyperlinked. Again, I cannot make the examples work with my data.

I'm using a 2D list of data, as I described terribly.

For the error, I lazily retyped the message and did not capitalize the color in the error; in the data files, the colors are capitalized (see colors.csv). Also, with the ToExpression command, I'm able to verify that the colors are imported correctly.

With a random array of colors, I receive the same error.

I've attached two files, examples of what I'm using; you can re-create the plot I previously screen captured with data.csv.

Attachments:
POSTED BY: Gary Lawson

Sander,

I followed your method exactly and the colors were properly rendered! Thank you very much for the help! And tally was a great addition, I was not aware of this function before and proves helpful as well.

POSTED BY: Gary Lawson

Very hard to give you the answer without knowing the data! Have you looked at the examples?

data = Flatten[
   Table[{x, y, Sin[x y]}, {x, 0, 3, 0.1}, {y, 0, 3, 0.1}], 1];
colors = Table[Hue[RandomReal[]], {31 31}];
ListPlot3D[data, Mesh -> None, VertexColors -> colors]

works fine.

What are the dimensions of your data? Is it an 2D or 3D list? Regarding the colors, yours errors says it is "magenta" rather than Magenta, so the colors seem to be a list of strings rather than actual colors. Have you tried making colors using RandomColor with the correct dimensions to check?

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard