美文网首页
mathematica中BarLegend的Ticks重新标度问

mathematica中BarLegend的Ticks重新标度问

作者: phyiuang | 来源:发表于2021-09-02 14:16 被阅读0次

    处理前:

    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]]

    相关文章

      网友评论

          本文标题:mathematica中BarLegend的Ticks重新标度问

          本文链接:https://www.haomeiwen.com/subject/wrzqwltx.html