Skip to content
Advertisement

How to plot the fourth variable based on a given x, y and z coordinate framework

I have a numpy array with four columns and several rows. First column is my variable and three others are x, y and z coordinates, respectivly:

JavaScript

The first column has some discrete values, e.g. it is 1 or 2 or 3. Now, using matplotlib or any other useful library like seaborn) I want to plot these values in a 3d space created by the second, third and fourth column. For example, I want to represent 1 as red star symbols, 2 as a yellow rectangles and 3 as black squares. I do appreciate if any one help me to do so. I tried the following code but it did not give me what I want:

JavaScript

I want to have the automatic version of the following figure:

enter image description here

Advertisement

Answer

Scatter plots lead to your expected output and can easily be individualized. This example code should even work for more than just 3 cases (as long as you add marker styles and colors)

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement