masandlin
(Mitchell Sandlin)
August 31, 2016, 4:13pm
1
Is there a better way of plotting a series of vector points (x,y) than using the Graphics[] command, see attached. I am just trying to visualize all the individual vector points to get an idea of the total graph; however my method seems awful crude and not very visually appealing?
p1=Graphics[{PointSize[Large],Black,Point[{0,0}],Text["(0,0)",{0,0.1}]}];
p2=Graphics[{PointSize[Large],Black,Point[{4,0}],Text["(4,0)",{4,0.1}]}];
p3=Graphics[{PointSize[Large],Black,Point[{4,2}],Text["(4,2)",{4,2.1}]}];
p4=Graphics[{PointSize[Large],Black,Point[{0,2}],Text["(0,2)",{0,2.1}]}];
Show[p1,p2,p3,p4]
mthiel
(Marco Thiel)
August 31, 2016, 4:55pm
2
Hi,
if this is a list of points:
list = {{0, 0}, {4, 0}, {4, 2}, {0, 2}};
then this would generate your plot:
Graphics[{PointSize[Large], Black, Point[#], Text["(" <> StringTake[ToString[#], 2 ;; -2] <> ")", # + {0, 0.1}]} & /@ list]
Cheers,
Marco
PS: The labelling can be done more elegantly.
bgoodman11
(Benjamin Goodman)
August 31, 2016, 5:02pm
3
I’m late but I believe the labelling here should satisfy a more elegant approach.
pts = {
{0, 0}, {4, 0}, {4, 2}, {0, 2}
};
Graphics[{
{PointSize[Large], Point[pts]},
Inset[#, # + {0, 0.2}] & /@ pts
}]
Alternatively, moving away from Graphics,
ListPlot[Labeled[#, #] & /@ pts, Axes -> False]
and generally, for any list of vectors
plotVec =
Function[{pts},
ListPlot[Labeled[#, #] & /@ pts, Axes -> False, PlotRange -> All]];
all produce the same output.
mthiel
(Marco Thiel)
August 31, 2016, 7:07pm
4
Hi Ben,
you are right. But your labels contain curly brackets. Much of my labelling code is to replace them by round ones. Also I was not sure whether it was relevant that the labels be text like in the OP. I also wanted to maintain the Graphics structure.
Your Graphics suggestion with the parenthesis replaced could look like this:
pts = {{0, 0}, {4, 0}, {4, 2}, {0, 2}};
Graphics[{{PointSize[Large], Point[pts]},
Inset[StringReplace[
ToString[#], {"{" -> "(", "}" -> ")"}], # + {0, 0.2}] & /@ pts}]
or this if the Text is not required:
Graphics[{{PointSize[Large], Point[pts]}, Inset[MatrixForm[{#}], # + {0, 0.1}] & /@ pts}]
Cheers,
M.
bgoodman11
(Benjamin Goodman)
August 31, 2016, 7:24pm
5
Ah, I missed the detail of the parenthesis vs. brackets in the OP. Thanks.
You may try ListPlot with Labeled:
pts = {{0, 0}, {1/2, 1/2}, {1, 1}};
ListPlot[Map[Labeled[#, TraditionalForm[{#}]] &, pts]]