Tag Info

New answers tagged

6

Borrowing the analytically-fitted color matching functions cieX, cieY, cieZ and sRGBGamma from this answer, here is a function for generating the colors of the black body spectrum. The conversion being done here assumes a luminance (Y in the XYZ system) of 1: With[{planck = 1/((Exp[1.43877696*^7/(#1 #2)] - 1) #1^5) &, tab = Through[{cieX, cieY, ...


2

Here's my take. You can use either newVisibleSpectrum[] or myVisibleSpectrum[] as the underlying ColorFunction; I'll use the latter. (* smooth step function *) smoothStep3 = Compile[{{a, _Real}, {b, _Real}, {x, _Real}}, With[{t = Min[Max[0, (x - a)/(b - a)], 1]}, t*t*(3 - 2 t)], ...


5

(with many thanks to halirutan and kirma for their kind assistance) Here's a different take. In this article, piecewise Gaussian functions that approximate the CIE color matching functions are presented. For this answer, instead of just taking the coefficients from the paper directly, I used their proposed model in FindFit[], using a 1 nm tabulation of the ...


4

You can also approach this using images (rather than graphics). The command ColorCombine places image a in the red channel, b in the green channel, and c in the blue channel: Nx = 10; Ny = 10; a = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; b = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; c = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; ...


4

Or, if you want to produce a Graphics directly, these produce identical results: Graphics@Raster@Transpose[{a, b, c}, {3, 1, 2}] Graphics@Raster[MapThread[List, {a, b, c}, 2]]


3

It is as simple as Nx = 10; Ny = 10; a = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; b = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; c = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; ArrayPlot[Transpose[{a, b, c}, {3, 1, 2}], ColorFunction -> RGBColor] Now you can set ColorFunction -> RGBColor and you probably want to look into ...


15

It depends on the DistanceFunction used. "CIE76" and "CIE2000" are symmetric. However, "CIE94" and "CMC" are not. ColorDistance[##, DistanceFunction -> "CIE76"] & @@@ {{Red, Blue}, {Blue, Red}} (* {1.8401283, 1.8401283} *) ColorDistance[##, DistanceFunction -> "CIE94"] & @@@ {{Red, Blue}, {Blue, Red}} (* {0.73824131, 0.65806887} *) ...


4

Since you claim "the default plots are orangish", I infer that you are working with Plot3D. The coloring of surfaces in a 3D plot can be tricky because there are many options and directives that affect the visible coloring. Some of these options affect the lighting and others the intrinsic coloring. Let's look at some examples. Default lighting and ...


2

Another way using Graphics primitives Raster and Text: dimdata = Reverse@Dimensions@data; map = data[[All, ;; -2]] // Raster[#, {{0, 0}, Reverse@Dimensions@#}, MinMax@#, ColorFunction -> "Rainbow"] &; text = Text @@@ Thread[{data[[All, -1]], Thread@{First@dimdata, Range[Last@dimdata]} - 0.5}]; then Graphics[{map, text}, AspectRatio -> ...


2

SetOptions[Plot, PlotStyle -> Green] If you plan to plot several functions simultaneously, you'll need a list of colors, e.g., SetOptions[Plot, PlotStyle -> {Green, Blue, Yellow, Purple}]


6

Updated code Based on some wonderful comments below, here is some simplified, more robust code. MatrixPlot[ PadRight[Drop[data, None, -1], Dimensions[data]] , ColorRules -> {0 -> White} , Epilog -> MapIndexed[ Text[#1, Flatten[{Last[Dimensions[data]] - 0.5, #2 - 0.5}]] & , Reverse@data[[All, -1]] ] ] Original code Does this ...


4

The solution is to use Blend[{Black,Cyan}, <appropriate fraction>] Two examples: DensityPlot[ Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, ColorFunction -> (Blend[{Black, Cyan}, #] &) ] Plot[ {Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions", PlotStyle -> { Blend[{Black, Cyan}, 0], Blend[{Black, ...


24

You can also construct the image from Graphics primitive, which ultimately may give you more control: spectrum[list_List] := Graphics[ {Thickness[0.005], ColorData["VisibleSpectrum"][#], Line[{{#, 0}, {#, 1}}]} & /@ list, PlotRange -> {{380, 750}, {0, 1}}, PlotRangePadding -> None, ImagePadding -> All, AspectRatio -> 1/5, ImageSize ...


12

I prefer ListDensityPlot here as it gives flexibility to plot a range of data points. First of all, I define a function which generates a narrow spectrum around our desired wavelength: spec[wavelength_, width_] := Flatten[Table[{{x, 0, x}, {x, 1, x}}, {x, wavelength - width, wavelength + width, 0.1}], 1]; where we can specify wavelength and width of ...


2

I finally got around to fixing the routine in the math.SE answer the OP linked to. To make this answer self-contained, I'll reproduce the definitions here: GaussianCurvature[f_, {u_, v_}] := Simplify[(Det[{D[f, {u, 2}], D[f, u], D[f, v]}] Det[{D[f, {v, 2}], D[f, u], D[f, v]}] - Det[{D[f, u, v], D[f, u], D[f, v]}]^2)/ ...


6

Suppose these are img1 and img2 (in this example img2 is a Deuteranopia colour blindness effect with some contrast adjustment): You first convert them to the "HSB" colour space using ColorConvert[img1,"HSB"] and likewise for img2. All you then need to do is extract the values in the Saturation channel and pair them up: points = Transpose[ ...



Top 50 recent answers are included