1
$\begingroup$

I want to put (to the left of the point) j = 1 to the point (0,0), j = 2 to the point (0,1/149), j = 3 to the point (0,2/149) and j = N to the point (0,3/149).

Also put (to the right of the point) j = 1 to the point (1,0), j = 2 to the point (1,1/149), j = 3 to the point (1,2/149) and j = N to the point (1,3/149).

Also put the three points "..." vertically instead of horizontally.

It doesn't matter if it's not framed.

I tried it as follows:

data = Transpose@Table[{i - 1, (j - 1)/149}, {i, 1, 2}, {j, 4}];
c1 = ListPlot[data, PlotStyle -> Black,PlotMarkers -> {"\[FilledCircle]", 7}, AspectRatio -> 1];
c2 = ListLinePlot[{{{0, 0}, {0, 1}}, {{1, 0}, {1, 1}}}, PlotStyle -> Black, AspectRatio -> 1];
c = Show[c1, c2, Ticks -> None, Frame -> True, FrameTicks -> {{{{0, "j=1"}, {1/149, "j=2"}, {2/149, 
   "j=3"}, {(2/149) + (1/298), "..."}, {3/149, "j=N"}}, 
 Automatic}, {Automatic, Automatic}}]
$\endgroup$

1 Answer 1

3
$\begingroup$

You can use a combination of options FrameStyle, FrameTicksStyle and custom ticks:

data = Transpose @ Table[{i - 1, (j - 1)/149}, {i, 1, 2}, {j, 4}];
labels = Style[#, 16] & /@ {"j = 0", "j = 1",  "  ⋮  ", "j = N"};
ticks = Thread[{(Range[4] - 1)/149, labels, 0}];

ListPlot[data, 
  PlotStyle -> Directive[Black, PointSize[Medium]],
  PlotStyle -> Black,
  Frame -> True, Axes -> False,
  FrameTicks -> {{ticks, ticks}, {Automatic, None}},
  FrameTicksStyle -> {{Opacity[1], Opacity[1]}, { Automatic,  Opacity[0]}},
  FrameStyle -> {{Opacity[0], Opacity[0]}, { Automatic,  Opacity[0]}}, 
  Epilog -> {Thick, Black, Line[{{{0, 0}, {0, 3/149}}, {{1, 0}, {1, 3/149}}}]},
  ImageSize -> 500]

enter image description here

Alternatively, you can wrap the input data with Labeled:

sides =  {Left, Right};
dt = Table[Labeled[{i - 1, (j - 1)/149}, labels[[j]], sides[[i]]], {i, 1,  2}, {j, 4}];

ListPlot[dt, 
 Frame -> {{False, False}, {True, False}}, 
 PlotStyle -> Directive[Black, PointSize[Medium]],
 ImagePadding -> Scaled[.05], 
 PlotStyle -> None, 
 ImageSize -> 500, 
 Epilog -> {Thick, Black, Line[{{{0, 0}, {0, 3/149}}, {{1, 0}, {1, 3/149}}}]}]

enter image description here

$\endgroup$
4
  • $\begingroup$ It has been helpful but I still haven't been able to get the figure. The columns are missing and the x-axis must match j = 1. $\endgroup$
    – edwards
    Sep 3, 2019 at 3:41
  • $\begingroup$ @edwards, please see the new version. $\endgroup$
    – kglr
    Sep 3, 2019 at 4:25
  • $\begingroup$ Could the frame be removed and the axes appear so that the bottom point coincides with the x-axis? $\endgroup$
    – edwards
    Sep 3, 2019 at 5:10
  • $\begingroup$ @edward, you can use the second approach with Frame->False and Axes->{True, False}. $\endgroup$
    – kglr
    Sep 3, 2019 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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