I would like to create a plot where I have unconnected dots and some connected.
So far, I have figured out how to draw the dots.
My code is the following:
ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full]
I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots.
Do have any suggestions/hints on how to do that?
Thank you.
Answer
One possibility would be to use Epilog
with Line
:
ListPlot[
{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}},
Ticks -> {{1, 2, 3, 4}, None},
AxesStyle -> Thin,
TicksStyle -> Directive[Black, Bold, 12],
Mesh -> Full,
Epilog -> {
Line[
{{1, 1}, {2, 2}, {2, 5}, {3, 12}}
]
}
]
A bit more concise:
pts = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}};
ListPlot[
pts,
Ticks -> {{1, 2, 3, 4}, None},
AxesStyle -> Thin,
TicksStyle -> Directive[Black, Bold, 12],
Mesh -> Full,
Epilog -> {
Line[
pts[[{1, 2, 6, 15}]]
]
}
]
Comments
Post a Comment