Coloring and legending issue

  • Context: Mathematica 
  • Thread starter Thread starter djymndl07
  • Start date Start date
  • Tags Tags
    Plot
Click For Summary
SUMMARY

The discussion addresses a color mismatch issue in a plot generated using Mathematica, specifically with the ParametricPlot function. The color bar displays a single color, which does not correspond to the plotted values, leading to confusion. Additionally, a blue horizontal line appears unexpectedly in the plot, which the user seeks to remove. The user provides a code snippet that defines the effective potential and attempts to plot the results, but the color scale is incorrectly applied to the radius instead of the temperature values.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of ParametricPlot function in Mathematica
  • Knowledge of color functions and scaling in data visualization
  • Basic concepts of effective potential in physics
NEXT STEPS
  • Review Mathematica's documentation on ParametricPlot and ColorFunction
  • Learn about the Rescale function in Mathematica for proper color mapping
  • Investigate methods to debug unexpected plot artifacts in Mathematica
  • Explore advanced color bar customization techniques in Mathematica
USEFUL FOR

This discussion is beneficial for physicists, data scientists, and Mathematica users who are working on visualizing complex data and require accurate color representation in their plots.

djymndl07
Messages
24
Reaction score
1
Look at the following Image.
The results are okay but clearly the plot colors does not match with the color bar. for example the color bar is showing only single color. the value 0.4 in color bar corresponds to the radius 0.8 which is different color in the plot.

Another issue is that I don't know why that blue horizontal line is there at one side of the center. That should not be there.

I am using the following code-

f[r_] := 1 - (2*M)/r + Q^2/r^2 + (8/3)*Pi*P*r^2
mass = (3*Q^2 + 3*r^2 + 8*P*Pi*r^4)/(6*r) /. r -> rh;
T[r_] := (-Q^2 + r^2 + 8*P*Pi*r^4)/(4*Pi*r^3)
veff[r_] := f[r]/r^2
rp = r /. Last[NSolve[D[veff[r], r] == 0, r, Reals]] /. M -> mass

rs = rp/Sqrt[f[rp]] /. M -> 0.9;
Q = 0.1;
P = 0.3315;

plot = ParametricPlot[{rs*Cos[\[Theta]], rs*Sin[\[Theta]]}, {rh, 0.37, 0.6}, {\[Theta],
0, 2*Pi}, Axes -> False, ColorFunctionScaling -> False,
ColorFunction -> Function[{x, y, rh}, ColorData["SunsetColors"][Rescale[T[rh],
{T[0.37],T[0.6]}]]],
PlotLegends -> BarLegend[{"SunsetColors", {T[0.37], T[0.6]}}, LegendLabel ->
Style[HoldForm[T], 14]]]



Can anyone help me? Thanks in advance.
plot.png
 
Last edited:
Physics news on Phys.org
Your color scale is based on T, but what you are plotting is rs. For rh in the range of the parametric plot, the values of rs go beyond the corresponding range in T, for example at rh = 0.6, rs ≈ 0.6, while the color scale goes tp to T[0.6] ≈ 0.53.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 1 ·
Replies
1
Views
937
Replies
13
Views
1K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K