2
$\begingroup$

I'm trying to produce a plot to compare two approximations which have in common the same parameter alpha.

I wish to get a plot like showed in the picture: Desired result

but I cannot combine the markers and width.

Here is my code:

pTLow[B_, pT_] := B^2/3*4/15*pT^2;
Bw01 = Table[{x, pLow[0.1, x]}, {x, 0.001, 2, 0.05}];

Bw03 = Table[{x, pLow[0.3, x]}, {x, 0.001, 2, 0.05}];

BTw05 = Table[{x, pTLow[0.5, x]}, {x, 0.001, 2,  0.05}];

BTw07 = Table[{x, pTLow[0.7, x]}, {x, 0.001, 2,  0.05}];

ListPlot[{Bw01, Bw03, Bw05, Bw07},PlotStyle -> {Black, Black, Black, Black},PlotMarkers -> {{"\[EmptyCircle]", 13}, {"\[FilledCircle]", 13}, {\[FilledSquare]", 13}, {"\[EmptySquare]", 13}},PlotRange -> Automatic, ImageSize->{600, 600}, AspectRatio -> 1,Frame -> True, FrameStyle -> Directive[Black, Thick, 23],PlotLegends -> {Placed[PointLegend[{"\[Alpha]=1", "\[Alpha]=2"},LegendMarkers -> {{"\[FilledCircle]" "\[EmptyCircle]",20}, {"\[FilledSquare]" "\[EmptySquare]",20}}], {Center,Top}]}]

This is the final result: Final output

As you can notice, there is a problem with the legend width.

$\endgroup$
1
  • 2
    $\begingroup$ Edit your question to include the code to produce the initial plot. $\endgroup$
    – Bob Hanlon
    Aug 10, 2020 at 23:12

1 Answer 1

2
$\begingroup$
ListPlot[{Bw01, Bw03, BTw05, BTw07}, PlotStyle -> Black, 
 PlotMarkers -> {{"○", 13}, {"●", 13}, {"■", 13}, {"□", 13}}, 
 PlotRange -> Automatic, ImageSize -> {600, 600}, AspectRatio -> 1, 
 Frame -> True, FrameStyle -> Directive[Black, Thick, 23], 
 PlotLegends -> Placed[PointLegend[{"α=1", "α=2"}, LegendMarkerSize -> {50, 30}, 
     LegendMarkers -> {{Row[{"●", "○"}, Spacer[5]], 20}, 
        {Row[{"■", "□"}, Spacer[5]],  20}}], {Center, Top}]]

enter image description here

Alternatively, change the option value for PlotLegends as follows:

PlotLegends ->  Placed[PointLegend[ {"", "α = 1", "", "α = 2"}, 
   LegendMarkers -> Thread[{{"●", "○", "■", "□"}, 20}], 
   LegendLayout -> (Grid[ArrayReshape[#, {2, 4}]] &)], {Center, Top}]

to get

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.