Skip to main content
deleted 13 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

We start by defining a function for visualizing color functions:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

We start by defining a function for visualizing color functions:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

We start by defining a function for visualizing color functions:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

added 2 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

We start by defining a function for visualizing color schemesfunctions:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

We start by defining a function for visualizing color schemes:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

We start by defining a function for visualizing color functions:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

added 484 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

We start by defining a function for visualizing color schemes:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

We start by defining a function for visualizing color schemes:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

We start by defining a function for visualizing color schemes:

colorbar[cf_] := DensityPlot[
  x,
  {x, 0, 370},
  {y, 0, 50},
  ColorFunction -> cf,
  ColorFunctionScaling -> True,
  AspectRatio -> Automatic,
  PlotRangePadding -> 10,
  FrameTicks -> {
    {None, None},
    {
     Transpose[{
       Subdivide[370, 5],
       N@Subdivide[5]
       }],
     None}
    }]

The problems that you mention can be solved using Rescale.

Using only a part of the rainbow color scheme:

cf = ColorData["Rainbow", Rescale[#, {0, 1}, {0.25, 1}]] &;
colorbar[cf]

Output

Using only a part of the visible spectrum color function:

cf = ColorData["VisibleSpectrum", Rescale[#, {0, 1}, {625, 750}]] &;
colorbar[cf]

Output

Combining parts from different color functions:

cf = Which[
    # < 0.8,
    ColorData["Rainbow", Rescale[#, {0, 0.8}, {0.25, 1}]],
    # >= 0.8,
    ColorData["VisibleSpectrum", Rescale[#, {0.8, 1}, {625, 750}]]
    ] &;
colorbar[cf]

Output

Another way is to sample colors from the color functions and put them together using Blend:

cf = Blend[Join[
     Table[
      {0.8 (x - 0.25)/(1 - 0.25), ColorData["Rainbow", x]},
      {x, 0.25, 1, 0.01}],
     Table[
      {0.8 + 0.2 (x - 625)/(750 - 625), 
       ColorData["VisibleSpectrum", x]},
      {x, 625, 750}
      ]
     ], #] &;
colorbar[cf]

Output

Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269
Loading