0
$\begingroup$

I am trying to plot a 2D data as points using Graphics function. I would like to plot the points as six or five-pointed star; how to do that using Graphics? Also I would like to plot these points using a plotrange kind of thing, e.g. I have a dataset where x-column values range from 0.8 to 4.5 and y-values range from 0 to 4.5; I would like to plot the data using a plotrange: {{0.8,2.1},{0,2.0}} and I am using Graphics[Points[Most#@]]&/@data, when I am doing this all data points are being plotted beyond the plotrange I want them to be plotted for. How do I use a PlotRange like function to use in graphics. Any help will be appreciated, thank you.

$\endgroup$
3
  • 1
    $\begingroup$ Please post a complete example. $\endgroup$
    – cvgmt
    Jan 18, 2022 at 9:25
  • 1
    $\begingroup$ What do you mean by x=(0,100)? Are you looking for something like this? over some range? Please load your data. $\endgroup$
    – Syed
    Jan 18, 2022 at 10:06
  • $\begingroup$ ListPlot[data, PlotMarkers -> Style[\[FivePointedStar], 14]] or with Style[\[SixPointedStar], 14] $\endgroup$
    – Bob Hanlon
    Jan 18, 2022 at 15:16

2 Answers 2

4
$\begingroup$

Using PolygonMarker:

datasets = RandomReal[{0 , 2.5}, {4, 20, 2}];

Graphics[{FaceForm[], EdgeForm[{AbsoluteThickness[1], JoinForm["Miter"]}],
  EdgeForm[Blue], 
  ResourceFunction["PolygonMarker"]["SixPointedStarSlim", Offset[7], datasets[[1]]],
  EdgeForm[Red], 
  ResourceFunction["PolygonMarker"]["FivePointedStarThick", Offset[7], datasets[[2]]],
  EdgeForm[Darker@Green], 
  ResourceFunction["PolygonMarker"]["SixPointedStar", Offset[7], datasets[[3]]],
  EdgeForm[Darker@Yellow], 
  ResourceFunction["PolygonMarker"]["FivePointedStar", Offset[7], datasets[[4]]]},
 AspectRatio -> 1/2, ImageSize -> 550, Frame -> True, PlotRange -> {{0.8, 2.1}, {0, 2.0}},
  PlotRangeClipping -> True]

plot

$\endgroup$
2
  • $\begingroup$ Thanks Alexey, this is working well $\endgroup$
    – mjm
    Jan 19, 2022 at 15:27
  • $\begingroup$ @mjm You are welcome! $\endgroup$ Jan 19, 2022 at 15:32
6
$\begingroup$

Something like:

Clear["Global`*"]
dat = RandomReal[{0, 1}, {10, 2}];
t1 = 0.02 Table[{Cos[p], Sin[p]}, {p, 0, 2 Pi, 2 Pi/5}];
t2 = 0.005 Table[{Cos[p], Sin[p]}, {p, 2 Pi/10, 2 Pi, 2 Pi/5}];
star[r_] := Line[(r + #) & /@ Riffle[t1, t2]]
Graphics[star /@ dat]

enter image description here

$\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.