2
$\begingroup$

enter image description here

I am struggling to plot discrete set of lines ( black dashed line around the black point) along with a continuous plot ( blue and yellow curves).

Following is the problem: Basically i want to plot some discrete points connected by dashed lines around each black solid dot. I can plot the continuous curves (blue, yellow curves), but don't know how to plot dashed lines around each back solid points. Here dashed lines around each black dot just connects some discrete points .

$\endgroup$
1
  • 3
    $\begingroup$ Please add sample data $\endgroup$
    – MarcoB
    Apr 6, 2023 at 2:08

2 Answers 2

3
$\begingroup$

Here is something to get you started:

pts = {{1, .5}, {2, -.5}};
line[pt_] := {PointSize[0.02], Point[pt], Dashing[Medium], 
  Line[(pt + #) & /@ Table[{x, x^2}, {x, -0.5, 0.5, 0.2}]]}
Plot[Sin[x], {x, 0, 2 Pi}, Epilog -> (line /@ pts)]

enter image description here

Addendum

If you want to plot a line through some given points, you may proceed as:

pts = {{1., .5}, {2., -.5}};
lines = {{{0.8, 0.6}, {0.9, 0.65}, {1, 0.65}, {1.1, 0.65}, {1.2, 
     0.7}}, {{1.8, -0.6}, {1.9, -0.65}, {2, -0.65}, {2.1, -0.65}, \
{2.2, -0.7}}};
Plot[Sin[x], {x, 0, 2 Pi}, 
 Epilog -> {PointSize[0.02], Point[pts], Dashing[Small], Line[lines]}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks for the answer. You chose a parabolic curve around the black dots. I need to connect some discrete points around the black dots by dashed lines. In your example, Suppose consider the point {1, .5}. As you have shown, I want to plot this point black solid circle. In addition, I have some discrete points around {1, .5}, let's say {0.95, o.6},{0.9,0.65} and {1.1,0.65},{1,2, 0.7} which I want to connect by dashed lines. Could you please help with this? $\endgroup$
    – Rakesh
    Apr 6, 2023 at 22:36
  • $\begingroup$ @PRakeshKumarDora Reiterating what was commented to the question, it will really help to answer this question if you provide some sample data, even if it is not real data. I suggest giving it in the same format as what you will be working with, so that it is easier to transfer the answer to your actual use case. This will improve the question & answers for you and future users as well. $\endgroup$ Apr 7, 2023 at 2:43
  • $\begingroup$ I added lines through given points. $\endgroup$ Apr 7, 2023 at 9:22
1
$\begingroup$

I am reading your question as asking for large black dots connected by dashed lines. Then display that along with some continuous plots. Here is a go, with that reading of your question.

        data = {{0.5 Pi, 0.90}, {Pi, 0.95}, {1.25 Pi, 0.5}, {1.5 Pi, 0.25}};
        lp = ListPlot[data, PlotStyle -> {PointSize[Large], Black}];
        llp = ListLinePlot[data, PlotStyle -> {Black, Dashed}];
        sinPlot = Plot[Sin[x], {x, 0, 2 Pi}];
        Show[sinPlot , lp, llp]

Output of above code

You can generate the ListPlot of large black dots, the dashed line with ListLinePlot, and then use show to put it all together.

$\endgroup$

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