3
$\begingroup$

I am plotting Abs[R] on y-axis vs k on x-axis with the following code

ϖ = -2 Cos[κ];
α = 1;
Subscript[V, 0] = -2.5;
ε = 0.05;
μ = 0.3;
  Subscript[V, 1] = Subscript[V, 0] (1 + ε);
  Subscript[V, 2] = Subscript[V, 0] (1 - ε);
  Subscript[δ, 2] = 
  Subscript[V, 2] - ϖ + (α*(Abs[R]))/(
  1 + μ*(Abs[R]));
  Subscript[δ, 1] = 
  Subscript[V, 
  1] - ϖ + (α*(Abs[R])*(1 - 
  2 Subscript[δ, 2]*Cos[κ] + Subscript[δ, 
  2]^2))/(1 + μ*(Abs[R])*(1 - 
   2 Subscript[δ, 2]*Cos[κ] + Subscript[δ, 
   2]^2)) ;
 χ = -κ;
 Subscript[ζ, 2] = 
 Subscript[V, 1] - ϖ + (α*(Abs[R]))/(
 1 + μ*(Abs[R]));
Subscript[ζ, 1] = 
Subscript[V, 
2] - ϖ + (α*(Abs[R])*(1 - 
  2 Subscript[ζ, 2]*Cos[χ] + Subscript[ζ, 
  2]^2))/(1 + μ*(Abs[R])*(1 - 
   2 Subscript[ζ, 2]*Cos[χ] + Subscript[ζ, 2]^2))
;

Then the plot command

g1 = DensityPlot[{(Abs[(E^(I κ) - 
       E^(-I κ))/(1 + (Subscript[δ, 1] - E^(
          I κ)) (E^(I κ) - Subscript[δ, 
          2]))]^2 - 
   Abs[(E^(I χ) - 
       E^(-I χ))/(1 + (Subscript[ζ, 1] - E^(
          I χ)) (E^(I χ) - Subscript[ζ, 
          2]))]^2)/(Abs[(E^(I κ) - 
       E^(-I κ))/(1 + (Subscript[δ, 1] - E^(
          I κ)) (E^(I κ) - Subscript[δ, 
          2]))]^2 + 
   Abs[(E^(I χ) - 
       E^(-I χ))/(1 + (Subscript[ζ, 1] - E^(
          I χ)) (E^(I χ) - Subscript[ζ, 
          2]))]^2)} /. {Abs[R] -> x}, {κ, 0, π}, {x, 0,
10}, ColorFunction -> ColorData["SolarColors"], PlotPoints -> 200,
  PlotRange -> All, AspectRatio -> 21/27, ImageSize -> 272, 
  Frame -> True, Axes -> True, 
  FrameLabel -> {κ, Style[Abs[R]^2, 21]}, 
  FrameStyle -> Directive[Black, FontSize -> 18], 
  FrameTicks -> {{{0, 2, 4, 6, 8, 10}, None}, {{0, 1, 2, 3}, None}}]

I get an output which I believe is close to the desired one, but due to the wrong choice of colors (maybe) i can not match mine with the following which is the desired output, Can someone please help change the ColorFunction, so that I can get as close to the desired as possible. The required output with legend isenter image description here

enter image description here

$\endgroup$
  • $\begingroup$ do you have image of the scale or legend ? $\endgroup$ – David Baghdasaryan Aug 13 '18 at 12:34
  • $\begingroup$ @DavidBaghdasaryan, I updated the post with the legend. $\endgroup$ – AtoZ Aug 14 '18 at 2:56
1
$\begingroup$

This is how you can overcome this problem: You can get the pixel values corresponding to the function from legend picture like:

data = {{0, 0, 0}, {77, 0, 0}, {149, 0, 0}, {231, 0, 0}, {255, 60, 0}, {255, 135, 0}, {255, 222, 0}, {255, 255, 42}, {255, 255, 118}, {255, 254, 187}, {255, 255, 255}};,

than you can interpolate, rescaling the doman from {-1,1} to {0,1} (because it seems that ColorFunction clips the values to be positive) :

f = Interpolation[Transpose[{Range[0, 1, 0.1], 1/255. (data)}], x]; colorfunc[x_] = RGBColor[f];

and then plot your function with additional options:

g1 = DensityPlot[{(Abs[(E^(I κ) - E^(-I κ))/(1 + (Subscript[δ, 1] - E^( I κ)) (E^(I κ) - Subscript[δ, 2]))]^2 - Abs[(E^(I χ) - E^(-I χ))/(1 + (Subscript[ζ, 1] - E^( I χ)) (E^(I χ) - Subscript[ζ, 2]))]^2)/(Abs[(E^(I κ) - E^(-I κ))/(1 + (Subscript[δ, 1] - E^( I κ)) (E^(I κ) - Subscript[δ, 2]))]^2 + Abs[(E^(I χ) - E^(-I χ))/(1 + (Subscript[ζ, 1] - E^( I χ)) (E^(I χ) - Subscript[ζ, 2]))]^2)} /. {Abs[R] -> x}, {κ, 0, π}, {x, 0, 10}, PlotPoints -> 200, PlotRange -> All, AspectRatio -> 21/27, ImageSize -> 272, ColorFunction -> colorfunc, PlotLegends -> Automatic, Frame -> True, Axes -> True, FrameLabel -> {κ, Style[Abs[R]^2, 21]}, FrameStyle -> Directive[Black, FontSize -> 18], FrameTicks -> {{{0, 2, 4, 6, 8, 10}, None}, {{0, 1, 2, 3}, None}}].

I get this:

enter image description here

BTW, it seems like the function that you are plotting is a bit different from the image.

$\endgroup$
  • $\begingroup$ Thanks. Could you please write the full code with the corrections you made to generate the output? $\endgroup$ – AtoZ Aug 14 '18 at 15:38
  • $\begingroup$ Sure, I just added two options ColorFunction -> colorfunc, PlotLegends -> Automatic $\endgroup$ – David Baghdasaryan Aug 15 '18 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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