处理前:
f[x_, y_] := x^2 + y^2
fTab = Flatten[ Table[{x, y, f[x, y]}, {x, -1, 1, 0.1}, {y, -1, 1, 0.1}], 1];
Leg = PlotLegends -> Placed[BarLegend[{"Rainbow", {-1, 1}},
LegendLayout -> "ReversedRow", LegendMarkerSize -> 200,
LegendLabel -> Placed["f(x,y)", Left],
LabelStyle -> Directive[FontSize -> 15]], {0.5, 0.1}];
ListDensityPlot[fTab, ColorFunction -> "Rainbow",Evaluate[Leg])]
处理后:
f[x_, y_] := x^2 + y^2
makeTicks[range_, num_] := Rescale[#, {1, num}, range] & /@ Range[num]
fTab = Flatten[ Table[{x, y, f[x, y]}, {x, -1, 1, 0.1}, {y, -1, 1, 0.1}], 1];
Leg = PlotLegends -> Placed[BarLegend[{"Rainbow", MinMax@{-1, 1}},
LegendLayout -> "Row",
LegendMarkerSize -> 100,
LabelStyle ->Directive[FontSize -> 15, FontColor -> Red, FontFamily -> "Times New Roman"],
Ticks -> makeTicks[MinMax[{-1, 1}], 2]], {0.8, 0.15}];
ListDensityPlot[fTab, ColorFunction -> "Rainbow", Evaluate[Leg]]
网友评论