0
$\begingroup$

I've got a CSV file that looks like this:

c1,c2,m1,m2,m3
'a','b',1,0.5,4
...
'x','y',10,100,4.21

Where c1 & c2 are 'coordinates' and ms are values of 3 different functions (each one - of two arguments (c1, c2)).

Is it possible to build a 3D Plot containing values of this ms (all at once), where axes are labelled 'a', ..., 'x' and 'b', ..., 'y'?

Update: seeing as my question needs clarification, let's assume for the sake of simplicity that there is only one m in the table.

c1,c2,m1
'a','b',1,0.5,4
'b','a',2,3,4
'x','y',10,100,4.21
'y','x',12,20,40

Now, I'd like to draw a 3D plot, where X-axis and Y-axis would be labeled with a, b, x, y, and Z-axis will be an ordinary real-valued axis (with values from e.g. 0 to 150), and each value of the m column would be located at coordinates e. g. ('a', 'b', 1).

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Apr 21 '15 at 19:43
  • 2
    $\begingroup$ Please clarify your question, which I (at least) have trouble understanding. Thanks. $\endgroup$ – bbgodfrey Apr 21 '15 at 19:44
  • $\begingroup$ I too feel this question needs clarification. Among other things you say a 3D plot yet you only indicate two axes? $\endgroup$ – Mr.Wizard Apr 21 '15 at 19:48
3
$\begingroup$

Is this what you want?

data = {
  {"a", "b", 1, 0.5, 4},
  {"x", "y", 10, 100, 4.21}
};
numericdata = data;
numericdata[[All, 1]] = Range[1, Length[numericdata]]; (**)
numericdata[[All, 2]] = Range[1, Length[numericdata]]; (**)
ListPointPlot3D[
  {
    numericdata[[All, {1, 2, 3}]],
    numericdata[[All, {1, 2, 4}]],
    numericdata[[All, {1, 2, 5}]]
  },
  Ticks -> {
    Transpose[{numericdata[[All, 1]], data[[All, 1]]}],
    Transpose[{numericdata[[All, 2]], data[[All, 2]]}],
    Automatic
  }
]

The lines marked with (**) are to be modified by you, depending on what numbers you want those characters to be mapped to for plotting purpose. In the example I use {1, 2} for both {"a", "x"} and {"b", "y"}.

And if you'd like the points to be connected by lines, you can start from the following example:

Graphics3D[
  {
    PointSize[Large],
    Red,
    Through@{Point, Line}[numericdata[[All, {1, 2, 3}]]],
    Green,
    Through@{Point, Line}[numericdata[[All, {1, 2, 4}]]],
    Blue,
    Through@{Point, Line}[numericdata[[All, {1, 2, 5}]]]
  },
  Axes -> True,
  BoxRatios -> {1, 1, 1},
  Ticks -> {
    Transpose[{numericdata[[All, 1]], data[[All, 1]]}],
    Transpose[{numericdata[[All, 2]], data[[All, 2]]}],
    Automatic
  }
]

alternative to ListLinePlot3D

$\endgroup$
  • $\begingroup$ Yes, this is exactly what I wanted. I got this image: https : // i.imgur.com/ELDnBFi.png using your method, it looks pretty much as I wanted it to. Is there by any chance a possibility to connect those dots with the line? I tried using ListPlot3D, but the output was an empty box. $\endgroup$ – tkroman Apr 21 '15 at 20:39
  • $\begingroup$ I've updated the answer for that. Use Graphics3D instead of ListPointPlot3D. $\endgroup$ – Taiki Apr 21 '15 at 23:18
  • $\begingroup$ Thank you, this is exactly what I wanted. $\endgroup$ – tkroman Apr 22 '15 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.