English 中文(简体)
根据标签在数学领域划出有色的地块
原标题:Coloring plot in Mathematica according to labels

我有一个带有标签的数据集,我想以根据其标签标明的点。 如何在地块内找到目前线数,以便我能够确定哪一类点属于什么?

我的理解是,<代码>x,y,z是计划数据坐标,但它无助于外部标签。

这非常令人怀疑,它只是以定期分发的分类数据。

    data = Import["http://ftp.ics.uci.edu/pub/machine-learning-databases/iris/iris.data"];
    data = Drop[data, -1]; (*there one extra line at the end*)
    inData = data[[All, 1 ;; 4]];
    labels = data[[All, 5]];
    ListPlot3D[inData,
      ColorFunction -> 
        Function[{x, y, z}, 
          If[y < 0.33, RGBColor[1, 1, 0.], 
               If[y < 0.66, RGBColor[1, 0, 0.], RGBColor[1, 0, 1]]
          ]
        ]
    ]

预期结果:

“expected

最佳回答

坐标表和<编码> a 相应标签清单,例如

points = Flatten[Table[{i, j, Sin[i j]}, 
   {i, 0, Pi, Pi/20}, {j, 0, Pi, Pi/10}], 1];
labels = RandomChoice[{"label a", "label b", "label c"}, Length[points]];

每一标签均以我书写的颜色作为规则清单,例如,

rules = {"label a" -> RGBColor[1, 1, 0], 
   "label b" -> RGBColor[1, 0, 0], "label c" -> RGBColor[1, 0, 1]};

然后可以按其标签的颜色划出各点:

ListPointPlot3D[Pick[points, labels, #] & /@ Union[labels], 
   PlotStyle -> Union[labels] /. rules]

<><>Edit>/strong>

在<代码>ListPlot3D中添加个点 您可使用<条码>。

ListPlot3D[points, VertexColors -> labels /. rules, Mesh -> False]

“在清单Plot3D中的栏目”。</p

问题回答

例:

(* Build the labeled structure and take a random permutation*)
f[x_, y_] = Sqrt[100 - x x - y y];
l = RandomSample@Flatten[{Table[{{"Lower", {x, y, f[x, y] - 5}},
                                 {"Upper", {x, y, 5 - f[x, y]}}},
                          {x, -5, 5, .1}, {y, -5, 5, .1}]}, 3];
(*Plot*)

Graphics3D[
 Riffle[l[[All, 1]] /. {"Lower" -> Red, "Upper" -> Green}, 
  Point /@ l[[All, 2]]], Axes -> True]

“entergraph





相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签