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.
$\begingroup$
$\endgroup$
3
2 Answers
$\begingroup$
$\endgroup$
2
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]
-
$\begingroup$ Thanks Alexey, this is working well $\endgroup$mjm– mjm2022-01-19 15:27:36 +00:00Commented Jan 19, 2022 at 15:27
-
$\begingroup$ @mjm You are welcome! $\endgroup$Alexey Popkov– Alexey Popkov2022-01-19 15:32:05 +00:00Commented Jan 19, 2022 at 15:32
$\begingroup$
$\endgroup$
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]


x=(0,100)? Are you looking for something like this? over some range? Please load your data. $\endgroup$ListPlot[data, PlotMarkers -> Style[\[FivePointedStar], 14]]or withStyle[\[SixPointedStar], 14]$\endgroup$