From: Marwa Abd El-Wahaab on 10 Feb 2010 03:35 Dear Sir, I am a Mathematica 7 user. I have two questions about Graphics3D[Point[my data]]; *First question:* * * How can I color some points in my data in the above "Graphics3D" by different colors? *Second question:* How can I represent some points also in my data in the above "Graphics3D" by shapes like squares , some like triangles and some like circles ? I need your advice. Marwa Ali
From: Bob Hanlon on 11 Feb 2010 06:13 myData = RandomReal[{-2, 2}, {100, 3}]; Assign color to each point Graphics3D[{ ColorData["Rainbow"] [Rescale[Sqrt[#.#], {0, 2 Sqrt[3]}]], AbsolutePointSize[10], Point[#]} & /@ myData, Axes -> True] Same plot using ListPointPlot3D ListPointPlot3D[myData, BoxRatios -> {1, 1, 1}, PlotStyle -> AbsolutePointSize[10], ColorFunction -> (ColorData["Rainbow"] [Rescale[Sqrt[{##}.{##}], {0, 2 Sqrt[3]}]] &), ColorFunctionScaling -> False] Assign color by grouping of data ListPointPlot3D[ SplitBy[ SortBy[myData, #.# &], Round[Sqrt[#.#]] &], BoxRatios -> {1, 1, 1}, PlotStyle -> AbsolutePointSize[10]] Assign color and shape Module[{r}, Graphics3D[{ ColorData["Rainbow"] [Rescale[r = Sqrt[#.#], {0, 2 Sqrt[3]}]], Scale[If[r < Sqrt[3], Sphere, Cuboid] [#], .15]} & /@ myData, Axes -> True]] Bob Hanlon ---- Marwa Abd El-Wahaab <m.a.elwahaab(a)gmail.com> wrote: ============= Dear Sir, I am a Mathematica 7 user. I have two questions about Graphics3D[Point[my data]]; *First question:* * * How can I color some points in my data in the above "Graphics3D" by different colors? *Second question:* How can I represent some points also in my data in the above "Graphics3D" by shapes like squares , some like triangles and some like circles ? I need your advice. Marwa Ali -- Bob Hanlon
From: Bill Rowe on 11 Feb 2010 06:11 On 2/10/10 at 3:35 AM, m.a.elwahaab(a)gmail.com (Marwa Abd El-Wahaab) wrote: >I am a Mathematica 7 user. >I have two questions about Graphics3D[Point[my data]]; >*First question:* * * How can I color some points in my data in the >above "Graphics3D" by different colors? Add whatever colors you like in a list with the Point command. For example, setOne = RandomReal[1, {5, 3}]; setTwo = RandomReal[1, {5, 3}]; Show(a)Graphics3D[{PointSize[0.02], Red, Point[setOne], Green, Point[setTwo]}] >*Second question:* >How can I represent some points also in my data in the above >"Graphics3D" by shapes like squares , some like triangles and some >like circles ? I don't think you can literally do what you want here. Circles, squares and triangles are all 2D graphic objects which do not work well with 3D graphics. But you can use different shapes using an appropriate 3D primitive. For example, here are colored boxes Show(a)Graphics3D[{Red, Cuboid[# - .02, # + .02] & /@ setOne, Green, Cuboid[# - .02, # + .02] & /@ setTwo}] And here are colored balls Show(a)Graphics3D[{Red, Sphere[setOne, .02], Green, Sphere[setTwo, .02]}] And while it is clearly possible to build any graphic you like from primitives, for 3D plotting of data you might find ListPointPlot3D more convenient. ListPointPlot3D[{setOne, setTwo}, PlotStyle -> {{PointSize[.015], Red}, {PointSize[.015], Green}}]
From: David Park on 11 Feb 2010 06:13 random3DPoint := Array[RandomReal, 3] point3DSet = Table[random3DPoint, {5}]; To use different colors on the points you could use the VertexColors option of Point: Graphics3D[ {AbsolutePointSize[6], Point[point3DSet, VertexColors -> {Red, Red, Green, Green, Blue}] }] A second possibility is to extract sub-lists of points and color each list individually: Graphics3D[ {AbsolutePointSize[6], Red, Point[Part[point3DSet, {1, 2}]], Green, Point[Part[point3DSet, {3, 4}]], Blue, Point[Part[point3DSet, 5]] }] The second question is not so easy. You could define little squares, circles (Presentations has Circle3D and Disk3D), triangles, etc., as graphic primitives and then use them instead of Points. One could define these as 'unit size' objects in the xy-plane and then use the geometric transformations to scale, rotate and translate them into the place you want. But the trouble with 2D objects in 3D space is orientation. First you have to decide how to orient them and then their appearance depends on the ViewPoint. If you happen to see them edge on they are nearly invisible. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Marwa Abd El-Wahaab [mailto:m.a.elwahaab(a)gmail.com] Dear Sir, I am a Mathematica 7 user. I have two questions about Graphics3D[Point[my data]]; *First question:* * * How can I color some points in my data in the above "Graphics3D" by different colors? *Second question:* How can I represent some points also in my data in the above "Graphics3D" by shapes like squares , some like triangles and some like circles ? I need your advice. Marwa Ali
From: Sjoerd C. de Vries on 11 Feb 2010 05:16 Dear Marwa Ali, Let me first thank you for the polite salutation of your post. One thing to note: I assume the readers of this group will indeed be mostly male given the group's nerdy subject. However, I know of at least one female reader of this group. As such the salutation 'Dear Sir' might be considered improper. Anyways, if you want to plot data you may consider more specialised commands to do this. I'd say you could try ListPointPlot3D or its siblings. If you still want to use Graphics3D, coloring can be done by inserting a color before the drawing commands that should be in that color, for instance using RGBColor[r,g,b] or some named colors: Graphics3D[{Red,Point[{0,0,0}],RGBColor[0,1,0],Point[{1,1,1}]}]. ListPlot has the option PlotMarkers to specify the plot symbols. ListPointPlot3D doesn't have this option, but since markers are usually 2D they make less sense in 3D plots. Cheers -- Sjoerd On Feb 10, 10:35 am, Marwa Abd El-Wahaab <m.a.elwah...(a)gmail.com> wrote: > Dear Sir, > > I am a Mathematica 7 user. > > I have two questions about Graphics3D[Point[my data]]; > > *First question:* > * > * > How can I color some points in my data in the above "Graphics3D" by > different colors? > > *Second question:* > > How can I represent some points also in my data in the above "Graphics3D"= by > shapes like squares , some like triangles and some like circles ? > > I need your advice. > > Marwa Ali
|
Pages: 1 Prev: Upright \[Micro] in AxesLabel Next: LogPlot is blank when Exported as pdf |