0
$\begingroup$

I have the following test data

testData1 = Table[{x, Sqrt[x]}, {x, 0, 4, .2}];
testData2 = Table[{x, x^(1/3)}, {x, 0, 4, .2}];
testData3 = Table[{x, x^(1/5)}, {x, 0, 4, .18}];
testData4 = Table[{x, x^(1/9)}, {x, 0, 4, .18}];

I need to plot the above data using ListPlot with different markers placed inside the plot area.

I used the following code

ListPlot[{testData1, testData2, testData3, testData4}, 
 PlotMarkers -> {{\[FilledCircle], 15}, {\[FilledDiamond], 
    15}, {\[EmptySquare], 15}, {\[FilledSquare], 15}},
 PlotLegends -> Placed[{"a", "b", "c", "d"}, {Left, Top}]]

and got the following results

enter image description here

In the plot, I am not able to change the size of markers in the plot (data points).

How to change the shape, size of the markers both in plot and in legend?

$\endgroup$

2 Answers 2

1
$\begingroup$
Clear["Global`*"]

testData[1] = Table[{x, Sqrt[x]}, {x, 0, 4, .2}];
testData[2] = Table[{x, x^(1/3)}, {x, 0, 4, .2}];
testData[3] = Table[{x, x^(1/5)}, {x, 0, 4, .18}];
testData[4] = Table[{x, x^(1/9)}, {x, 0, 4, .18}];

If you want the legend labels to scale with the markers:

Manipulate[
 ListPlot[testData /@ Range[4],
  PlotRangePadding -> Scaled[0.05],
  PlotMarkers -> (Style[#, ms] & /@ {●, ◆, □, ■}),
  PlotLegends -> Placed[
    PointLegend[{"a", "b", "c", "d"},
     LegendMarkerSize -> ms,
     LabelStyle -> {FontSize -> ms}],
    Below]],
 {{ms, 15, "Marker Size"}, {Small, Medium, Large, 15, 18}}]

enter image description here

$\endgroup$
0
$\begingroup$
f[s_String] := Style[s, 18];
ListPlot[{testData1, testData2, testData3, testData4},
 PlotMarkers -> {f["\[FilledCircle]"], f["\[FilledDiamond]"], 
   f["\[EmptySquare]"], f["\[FilledSquare]"]}
 , PlotLegends -> Placed[{f["a"], f["b"], f["c"], f["d"]}, {Left, Top}]
 , ImageSize -> Large
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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