0
$\begingroup$

Simply, I would like to generate a such figure

enter image description here

Note that zero along y and x has different colors (White and Black), how can we do that? or there is another trick?

DensityPlot[x (Cos[\[Pi] y]), {x, 0, 1}, {y, 0, 1}, 
 ColorFunction -> (Blend[{Blue, White, Red}, Rescale[#, {-1, 1}]] &), 
 ColorFunctionScaling -> False, ImageSize -> 200, FrameTicks -> None]    

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

An approximation to the figure in the OP can be drawn as follow.

Graphics[Polygon[{{1, 0}, {1, 1}, {0.5, 1}, {0, 1}, {0, 
    0}, {0, -1}, {0.5, -1}, {1, -1}}, 
  VertexColors -> {Black, Red, Blend[{Red, White}], White, White, 
    White, Blend[{White, Blue}], Blue}]
 , AspectRatio -> 1
 , Frame -> True
 ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.