Message Boards Message Boards

0
|
4310 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Set dashed lines in plot points?

Posted 5 years ago

hi, i'made a graphic represantation of f(x)=2x function and i want to mark some of the points with dashed lines across the axes x and y.Can anybody help me please?Below i give you the code so far. Thank you.

Plot[{2 x}, {x, 0, 10}, PlotLabel -> ??????? ?????????, AxesLabel -> {?????????, ???????}, 
 Epilog -> {PointSize[Large], Point[{{0, 0}, {1, 2}, {2, 4}, {3, 6}, {6, 12}, {10, 20}}]}, 
 Ticks -> {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {0, 1, 2, 3, 5, 10, 12,15, 20}}]
2 Replies

Yes, thank you very much for the reply!

Posted 5 years ago

Hi Dimitris,

Is this what you are trying to do?

points = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {6, 12}, {10, 20}};
yAxisPoints = {0, Last[#]} & /@ points;
xAxisPoints = {First[#], 0} & /@ points;
yLines = {Directive[Dashed], Line[#]} & /@ Transpose[{points, yAxisPoints}];
xLines = {Directive[Dashed], Line[#]} & /@ Transpose[{points, xAxisPoints}];

Plot[{2 x}, {x, 0, 10}, 
 Epilog -> {PointSize[Large], Point[points], yLines, xLines}, 
 Ticks -> {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {0, 1, 2, 3, 5, 10, 12, 15, 20}}]

I left out the labels

enter image description here

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract