Hot answers tagged

7

There are 69,451 different polygons in the bunny, so that is why it takes so long to plot, so let's use a simpler example with only ~1,400 polygons: MeshVertices[mesh_] := First@Cases[mesh, GraphicsComplex[x_, __] :> x, Infinity] MeshFaces[mesh_] := Block[{faces}, faces = Cases[mesh, Polygon[x_, ___] :> x, Infinity]; If[faces == {}, ...


5

Grid[Item[#, Background -> If[# == 1, Blue]] & /@ # & /@ RandomInteger[{0, 1}, {10, 10}]] Grid[RandomInteger[{0, 1}, {10, 10}]] /. 1 -> Item[1, Background -> Blue] Grid[m = RandomInteger[{0, 1}, {10, 10}], Background -> {None, None, Thread[Position[m, 1] -> Blue]}]


5

I think this is a bug due to the creation of an improper SparseArray for the Raster of the ArrayPlot. ap = ArrayPlot[{{0}}, ColorFunction -> Function[a, RGBColor[a, a, a]], ColorFunctionScaling -> False]; {sa} = Cases[ap, _SparseArray, Infinity] The normal expression Normal[sa] {{0.}} looks OK, but InputForm[sa] ...


4

Jason already said a lot of what I wanted to say, so I'll just offer this little snippet that avoids Normal[] chicanery: gc = ExampleData[{"Geometry3D", "StanfordBunny"}, "GraphicsComplex"]; Graphics3D[Insert[gc, EdgeForm[], {2, 1}] /. Polygon[m_?MatrixQ] :> Riffle[Table[RandomColor[], {Length[m]}], Polygon /@ m]] Just for variety, ...


4

Here, finally, is the direct analog of newVisibleSpectrum from this answer, which can be used to replace ColorData["BlackBodySpectrum"]. ChromaticityPlot; (* pre-load internals *) newBlackBodySpectrum[t_?NumericQ] := With[{planck = 1/((Exp[1.43877696*^7/(# t)] - 1) #^5) &}, XYZColor @@ ({{1.0478112, 0.022886602, -0.050126976}, (* Bradford ...


4

Here's how to make all the color schemes in ColorBrewer available in Mathematica: ColorBrewer = Association /@ Association[Import["http://colorbrewer2.org/export/colorbrewer.json"] /. {s_String /; StringMatchQ[s, NumberString] :> FromDigits[s], s_String /; StringMatchQ[s, "rgb(*)"] :> Interpreter["Color"][s]} /. v_ /; VectorQ[v, ...


4

By manually converting the XYZColor[] colors into xy, we can generate the line easily. cols = {XYZColor[...], ...}; (* your list of colors *) ChromaticityPlot[cols, Epilog -> {Thick, Line[Most[Normalize[#, Total]] & @@@ cols, VertexColors -> cols]}] If the colors given are not XYZ colors, use ...


3

The ColorFunction for SphericalPlot3D takes 6 arguments, referring to the Cartesian and spherical coordinates. cf = ColorData["Rainbow"]; plot = SphericalPlot3D[ 1/((Sin[θ]^4* Cos[ϕ]^4*0.049896792) + (2*(Sin[θ]* Cos[ϕ])^2*(Sin[θ]* Sin[ϕ])^2*(-0.01555592)) + (2*(Sin[θ]* Cos[ϕ])^2*(Cos[θ])^2*(-0.030833372)) + ...


3

This is expected behavior since the values are all rescaled to lie between 0 and 1 prior to feeding them to the ColorFunction. So there will always be some portion of the plotted region that corresponds to a value of 0 and a region that corresponds to a value of 1. Look at this simplified example, DensityPlot[2 + UnitStep[x], {x, -3, 3}, {y, -3, 3}, ...


3

You can write your own converter like so: hue2HSB[color : Hue[h_, s_, b_]] := {360. h, 100. s, 100. b} then Hue[0.55, 0.73, 0.82] The next step would be to export the conversion, but since you don't indicate how you plan to do that, I can't say anything more.


3

Update: To connect the points in the original order, use ChromaticityPlot separately for each color, extract the projected coordinates and combine them: pts=Sequence@@@(ChromaticityPlot[#,Appearance->None][[1,2,1,2]]&/@colors); Show[cp, Epilog->{Thick,Line[pts,VertexColors->colors]} ] Using OP's new list of colors, we get Original ...


3

BubbleChart3D[data, ColorFunction -> (Hue[#4] &)] ListPointPlot3D[List /@ data[[;; , ;; 3]], BaseStyle -> PointSize[.025], PlotStyle -> (Hue /@ data[[All, 4]]), BoxRatios -> 1]


2

I recently needed to do something like this. The only wrinkle is that I did not find Manipulate[] to be sufficiently flexible for my needs, so I fell back on using DynamicModule[]. Hopefully, this is still admissible. With[{cmax = 12}, (* maximum number of colors *) DynamicModule[{k = 3, cols = {Red, White, Blue}, vals = {0., 0.5, 1.}}, ...


2

Graphics3D[{PointSize[Large], Hue[#[[4]]], Point[{#[[1]], #[[2]], #[[3]]}]} & /@ data]


2

To get the Plot3D to look the way it used to, use the option PlotTheme -> "Classic". Compare the current output, Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}] with what you get with the classic theme, Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotTheme -> "Classic"] If you want to make that change permanent, then add the line ...


2

Adding links to comment by MarcoB Note the Attributes of RegionPlot Attributes[RegionPlot] (* {HoldAll, Protected, ReadProtected} *) Since RegionPlot and other plot functions have attribute HoldAll you need to use Evaluate a = {x^2 < y^3 + 1, y^2 < x^3 + 1}; RegionPlot[Evaluate[a], {x, -2, 5}, {y, -2, 5}]


2

r = RandomInteger[{0, 1}, {10, 10}]; bg = Thread[SparseArray[r]["NonzeroPositions"] -> LightBlue]; Grid[r, Background -> {None, None, bg}]


1

You can also modify ColorFunctionof ListPointPlot3D. This is different from kglr's solution, because he's actually interpreting every point as a separate plot. ListPointPlot3D[data[[All, 1 ;; 3]], ColorFunctionScaling -> False, BaseStyle -> PointSize[.02], BoxRatios -> 1, ColorFunction -> Function[{x, y, z}, Hue@Last@Last@Select[data, ...


1

You can make an interpolating function from your data, that takes x, y, z as inputs and returns a color based on the matching value of n, colorfunc = Interpolation[{{#1, #2, #3}, #4} & @@@ Transpose[{x, y, z, n}], InterpolationOrder -> 1] ListPlot3D[Transpose[{x, y, z}], ColorFunction -> (ColorData[{"Rainbow", MinMax@n}][ ...



Only top voted, non community-wiki answers of a minimum length are eligible