New answers tagged

2

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 ...


1

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.}}, ...


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)) + ...


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, ...


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}, ...


0

Here is a very hack-ish way of coloring each residue sequentially. The trick is in constructing a Blend[] function where the color corresponding to each residue appears twice in the first argument. A slight shift is apparently needed to match up the colors, even if only approximately. n = StringLength[First[Import["ExampleData/1PPT.pdb", "Sequence"]]]; ...


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.


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, ...


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 == {}, ...


2

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


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 ...


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}][ ...


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]}]


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, ...


3

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


2

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


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 ...


0

There is definitely a bug in the color function rescaling of GeoRegionValuePlot. Here is an even simpler instance of the problem, {GeoRegionValuePlot[{Entity["Country", "Greenland"] -> 1, Entity["Country", "Brazil"] -> 5., Entity["Country", "Afghanistan"] -> 20}, ColorFunction -> "BlueGreenYellow"], ...


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 ...


0

For a verry nice Q & A see Using Evaluate and Evaluated -> True in Plot Plot[{{A0 E^(-k1 t) , -((A0 E^(-k1 t - k2 t) (-E^(k1 t) + E^(k2 t)) k1)/(k1 - k2)) , (A0 E^(-k1 t - k2 t) (-E^(k1 t) k1 + E^(k1 t + k2 t) k1 + E^(k2 t) k2 - E^(k1 t + k2 t) k2))/(k1 -k2)} /. {A0 -> 1, k1 -> 4, k2 -> 10}} , {t, 2, 0} , Evaluated -> True] Plot[{{A0 ...


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}]


3

Okay, so this is what it looks like with standard coloring of the residues: Import["ExampleData/1PPT.pdb", ColorFunction -> "Residue"] But now, if we want to change the residue colors, we need to change the value of a certain internal color list called Graphics`MoleculePlotDump`residueColorRules residuelist = {"Gly", "Pro", "Ser", "Gln", "Pro", ...


2

Cases[fplot, RGBColor[x_, y_, z_] :> {x, y, z}, Infinity] {{0.368417, 0.506779, 0.709798}, {0.880722, 0.611041, 0.142051}, {0.560181, 0.691569, 0.194885}, {0.922526, 0.385626, 0.209179}}


7

The following is a universal solution which extracts RGB color values assigned to the Line primitives of a plot generated by built-in plotting functions of Mathematica 10: Cases[fplot, {___, c_Directive, __Line} :> ColorConvert[c, RGBColor], Infinity] // InputForm {RGBColor[0.368417, 0.506779, 0.709798, 1.], RGBColor[0.880722, 0.611041, 0.142051, ...



Top 50 recent answers are included