1
$\begingroup$

Take a look at the following; my discrete points are chopped because of my choice of vertical plot range. If I increase that plot range to include my discrete points, I lose my "m" at the origin because the y-axis extends into the negative. I want both "complete points" and my "m". I tried preventing the y-axis from going negative and increasing the tick to tick label distance as describe in various SE posts, but was unsuccessful on both counts. (I was unable to use FrameMargins at the same time as specifying tick label names.) Best regards...

a = -6.13;
b = 6.13;
c = 0.0000001;
f[x_] := Abs[Sin[(π*(x - c))]/(π*(x - c))];
p = Table[{x, f[x]}, {x, -5, 5, 1}];
Show[Plot[f[x], {x, a, b}, PlotRange -> {{a, b}, {-0.0062, 1.1}},
  Ticks -> {{{-1.0, "m-1"}, {-5.0, "m-5"}, {0.0, "m"}, {5.0, 
      "m+5"}, {1.0, "m+1"}}, {{1.0, "A "}}}],
  DiscretePlot[f[x], {x, Floor[a], Floor[b], 1.0}, 
  PlotStyle -> Darker[Red]]]

Composite Plot, Tick labeling, Ranging

$\endgroup$
3
  • $\begingroup$ By the way, is there a better way to post a plot? This one looks fuzzy. $\endgroup$ Commented May 1, 2019 at 17:11
  • $\begingroup$ I usually use the Export[] command for graphs and add the option to increase image resolution like: Export["~/Desktop/plot1.png", plot1, ImageResolution -> 300]. That usually results in fairly crisp plots in my opinion. $\endgroup$
    – MassDefect
    Commented May 1, 2019 at 17:50
  • $\begingroup$ Nice! I'll do the same next time. Thanks... $\endgroup$ Commented May 2, 2019 at 6:11

1 Answer 1

4
$\begingroup$

Use PlotRangeClipping->False to avoid chopping the points. Also, the location of the dots could be improved by using an AxesOrigin option. The options should go either in the first plot, or as an option to Show:

Show[
    Plot[f[x], {x,a,b}, 
        PlotRange->{{a,b}, {-0.0062,1.1}},
        Ticks->{
            {{-1.0,"m-1"},{-5.0,"m-5"},{0.0,"m"},{5.0,"m+5"},{1.0,"m+1"}},
            {{1.0,"A "}}
        }
    ],
    DiscretePlot[f[x], {x, Floor[a], Floor[b], 1.0}, PlotStyle->Darker[Red]],
    PlotRangeClipping->False,
    AxesOrigin -> {0, -.0062}
]

enter image description here

$\endgroup$
1
  • $\begingroup$ Excellent - many thanks. $\endgroup$ Commented May 2, 2019 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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