Plot, sampling, and why it does not display for some rangesWhy does plot not show where Piecewise function is not zero?Problem with Piecewise functionPlot does not plot over the specified rangeHow specify PlotRange and display bitmap over plot in DateListPlot?How to plot the contour of f[x,y]==0 if always f[x,y]>=0Why does piecewise plot have a discontinuity when the function, first and second derivatives are equal?Can I make a smooth contour plot with Mathematica?

Can you marry a girl in Stardew Valley if you are a girl?

Secure Implementation of Password Database

Arrange 5 non-attacking knights on a 5x5 toroidal board

Should I replace fillable PDFs?

Any real contribution of functional analysis to quantum theory as a branch of physics?

Applying field calculator for multiple layers at once

How do I compile something for Linux if I don't have enough space for installing GCC?

Unable to register mirrored Deployer Capabilities

My boss asked what number would keep me happy?

Is it possible for nature to create bubble wrap?

VBA: Why would the Not operator stop working?

Finding IP return hex address

Is using Swiss Francs (CHF) cheaper than Euros (EUR) in Switzerland?

Can I ignore an open source license if I checkout a version that was released prior to the code having any license?

Finding the time domain equation corresponding to a given DFT

Fourier transform is an isomorphism...but we don’t get when each frequency appears?

What does "你舒服吗" mean in a relationship context?

Thoughts on if it's possible to succeed in math @ PhD level w/o natural ability in quant reasoning?

Why do aircraft cockpit displays use uppercase fonts?

Is there a Scoville scale for coldness?

Unexpected large rent payments, by moneygram, for my apartment, not by me

Why didn't the British consider the USS President's attempted flight as a fake surrender?

Why don't all States switch to all postal voting?

Do trolls appear to be dead after reaching 0 HP from non-fire/acid damage?



Plot, sampling, and why it does not display for some ranges


Why does plot not show where Piecewise function is not zero?Problem with Piecewise functionPlot does not plot over the specified rangeHow specify PlotRange and display bitmap over plot in DateListPlot?How to plot the contour of f[x,y]==0 if always f[x,y]>=0Why does piecewise plot have a discontinuity when the function, first and second derivatives are equal?Can I make a smooth contour plot with Mathematica?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;

.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;








8















$begingroup$


The following gives an empty plot on V12 under Windows 10:



f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]
Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Changing the range to make it little smaller, now shows it as:



Plot[f[x, 7], x, -20, 20 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Also increasing Plot points and using the longer range, it now shows as:



Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1,
Exclusions -> None, PlotPoints -> 20]


Mathematica graphics



OK, so I thought I needed more PlotPoints and that was all. But changing f[x, 7] to f[x,8] now shows it using the longer range and without changing the PlotPints:



Plot[f[x, 8], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



So there must be something else. It can't be the PlotPoints. Why would f[x, 7] need more points than f[x,8]?



The function only generates this:



Table[f[x, 7], x, 7, 8, .1]


Mathematica graphics



Table[f[x, 8], x, 8, 9, .1]


Mathematica graphics



BTW, this has nothing to do with odd or even numbers. It seems random. For example,



Plot[f[x, 2], x, -30, 30, PlotRange -> All, -1, 1, Exclusions -> None]


It also gives an empty plot.



The sampling algorithm for Plot seems to miss all the points from f[x, 7], but not from f[x, 8]. Why is that?










share|improve this question











$endgroup$














  • $begingroup$
    Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
    $endgroup$
    – xzczd
    Sep 30 at 4:40

















8















$begingroup$


The following gives an empty plot on V12 under Windows 10:



f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]
Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Changing the range to make it little smaller, now shows it as:



Plot[f[x, 7], x, -20, 20 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Also increasing Plot points and using the longer range, it now shows as:



Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1,
Exclusions -> None, PlotPoints -> 20]


Mathematica graphics



OK, so I thought I needed more PlotPoints and that was all. But changing f[x, 7] to f[x,8] now shows it using the longer range and without changing the PlotPints:



Plot[f[x, 8], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



So there must be something else. It can't be the PlotPoints. Why would f[x, 7] need more points than f[x,8]?



The function only generates this:



Table[f[x, 7], x, 7, 8, .1]


Mathematica graphics



Table[f[x, 8], x, 8, 9, .1]


Mathematica graphics



BTW, this has nothing to do with odd or even numbers. It seems random. For example,



Plot[f[x, 2], x, -30, 30, PlotRange -> All, -1, 1, Exclusions -> None]


It also gives an empty plot.



The sampling algorithm for Plot seems to miss all the points from f[x, 7], but not from f[x, 8]. Why is that?










share|improve this question











$endgroup$














  • $begingroup$
    Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
    $endgroup$
    – xzczd
    Sep 30 at 4:40













8













8









8


1



$begingroup$


The following gives an empty plot on V12 under Windows 10:



f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]
Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Changing the range to make it little smaller, now shows it as:



Plot[f[x, 7], x, -20, 20 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Also increasing Plot points and using the longer range, it now shows as:



Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1,
Exclusions -> None, PlotPoints -> 20]


Mathematica graphics



OK, so I thought I needed more PlotPoints and that was all. But changing f[x, 7] to f[x,8] now shows it using the longer range and without changing the PlotPints:



Plot[f[x, 8], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



So there must be something else. It can't be the PlotPoints. Why would f[x, 7] need more points than f[x,8]?



The function only generates this:



Table[f[x, 7], x, 7, 8, .1]


Mathematica graphics



Table[f[x, 8], x, 8, 9, .1]


Mathematica graphics



BTW, this has nothing to do with odd or even numbers. It seems random. For example,



Plot[f[x, 2], x, -30, 30, PlotRange -> All, -1, 1, Exclusions -> None]


It also gives an empty plot.



The sampling algorithm for Plot seems to miss all the points from f[x, 7], but not from f[x, 8]. Why is that?










share|improve this question











$endgroup$




The following gives an empty plot on V12 under Windows 10:



f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]
Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Changing the range to make it little smaller, now shows it as:



Plot[f[x, 7], x, -20, 20 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



Also increasing Plot points and using the longer range, it now shows as:



Plot[f[x, 7], x, -30, 30 , PlotRange -> All, -1, 1,
Exclusions -> None, PlotPoints -> 20]


Mathematica graphics



OK, so I thought I needed more PlotPoints and that was all. But changing f[x, 7] to f[x,8] now shows it using the longer range and without changing the PlotPints:



Plot[f[x, 8], x, -30, 30 , PlotRange -> All, -1, 1, Exclusions -> None]


Mathematica graphics



So there must be something else. It can't be the PlotPoints. Why would f[x, 7] need more points than f[x,8]?



The function only generates this:



Table[f[x, 7], x, 7, 8, .1]


Mathematica graphics



Table[f[x, 8], x, 8, 9, .1]


Mathematica graphics



BTW, this has nothing to do with odd or even numbers. It seems random. For example,



Plot[f[x, 2], x, -30, 30, PlotRange -> All, -1, 1, Exclusions -> None]


It also gives an empty plot.



The sampling algorithm for Plot seems to miss all the points from f[x, 7], but not from f[x, 8]. Why is that?







plotting sampling






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 30 at 15:56









Peter Mortensen

3622 silver badges7 bronze badges




3622 silver badges7 bronze badges










asked Sep 30 at 2:24









NasserNasser

73k4 gold badges95 silver badges220 bronze badges




73k4 gold badges95 silver badges220 bronze badges














  • $begingroup$
    Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
    $endgroup$
    – xzczd
    Sep 30 at 4:40
















  • $begingroup$
    Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
    $endgroup$
    – xzczd
    Sep 30 at 4:40















$begingroup$
Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
$endgroup$
– xzczd
Sep 30 at 4:40




$begingroup$
Related: mathematica.stackexchange.com/q/182993/1871 There should be more.
$endgroup$
– xzczd
Sep 30 at 4:40










2 Answers
2






active

oldest

votes


















7

















$begingroup$

Your plots aren't empty: they have a line along the x axis.



Plot uses PlotPoints -> 50 by default, and since you go from -30 to 30, there will be some $n$ to $n+1$ intervals that don't get sampled:



In[66]:= Reap[
Plot[x, x, -30, 30, MaxRecursion -> 0,
EvaluationMonitor :> Sow[x]];]

Out[66]= Null, -30., -28.8223, -27.5455, -26.3533, -25.1845,
-23.9167, -22.7335, -21.4512, -20.1922, -19.0179, -17.7446, -16.5558,
-15.3904, -14.126, -12.9462, -11.6673, -10.4118, -9.24087, -7.97091,
-6.78556, -5.50115, -4.24013, -3.06371, -1.78823, -0.597365, 0.570117,
1.83666, 3.0186, 4.2996, 5.55721, 6.73021, 8.00228, 9.18974,
10.3538, 11.6169, 12.7955, 14.0731, 15.266, 16.4356, 17.7043,
18.8883, 20.1714, 21.4312, 22.6063, 23.8804, 25.07, 26.2362,
27.5014, 28.6821, 30.


7 to 8, corresponding to f[x, 7] is one such interval. Since we don't sample between those values, we never see f[x,7] == 1 and the resulting plot is zero everywhere.






share|improve this answer










$endgroup$













  • $begingroup$
    But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
    $endgroup$
    – Nasser
    Sep 30 at 4:48







  • 4




    $begingroup$
    @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
    $endgroup$
    – Lukas Lang
    Sep 30 at 12:45


















6

















$begingroup$

Brett's answer explains the why.



To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) :



f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]

Plot[f[x, 7], x, -30, 30,
PlotPoints -> 50, 7,
PlotStyle -> CapForm["Butt"],
Axes -> False, Frame -> True,
PlotRange -> -1, 1,
PlotRangePadding -> Scaled[.05]]


enter image description here



Add Exclusions -> None to get the vertical portions:



enter image description here






share|improve this answer












$endgroup$















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207091%2fplot-sampling-and-why-it-does-not-display-for-some-ranges%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7

















    $begingroup$

    Your plots aren't empty: they have a line along the x axis.



    Plot uses PlotPoints -> 50 by default, and since you go from -30 to 30, there will be some $n$ to $n+1$ intervals that don't get sampled:



    In[66]:= Reap[
    Plot[x, x, -30, 30, MaxRecursion -> 0,
    EvaluationMonitor :> Sow[x]];]

    Out[66]= Null, -30., -28.8223, -27.5455, -26.3533, -25.1845,
    -23.9167, -22.7335, -21.4512, -20.1922, -19.0179, -17.7446, -16.5558,
    -15.3904, -14.126, -12.9462, -11.6673, -10.4118, -9.24087, -7.97091,
    -6.78556, -5.50115, -4.24013, -3.06371, -1.78823, -0.597365, 0.570117,
    1.83666, 3.0186, 4.2996, 5.55721, 6.73021, 8.00228, 9.18974,
    10.3538, 11.6169, 12.7955, 14.0731, 15.266, 16.4356, 17.7043,
    18.8883, 20.1714, 21.4312, 22.6063, 23.8804, 25.07, 26.2362,
    27.5014, 28.6821, 30.


    7 to 8, corresponding to f[x, 7] is one such interval. Since we don't sample between those values, we never see f[x,7] == 1 and the resulting plot is zero everywhere.






    share|improve this answer










    $endgroup$













    • $begingroup$
      But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
      $endgroup$
      – Nasser
      Sep 30 at 4:48







    • 4




      $begingroup$
      @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
      $endgroup$
      – Lukas Lang
      Sep 30 at 12:45















    7

















    $begingroup$

    Your plots aren't empty: they have a line along the x axis.



    Plot uses PlotPoints -> 50 by default, and since you go from -30 to 30, there will be some $n$ to $n+1$ intervals that don't get sampled:



    In[66]:= Reap[
    Plot[x, x, -30, 30, MaxRecursion -> 0,
    EvaluationMonitor :> Sow[x]];]

    Out[66]= Null, -30., -28.8223, -27.5455, -26.3533, -25.1845,
    -23.9167, -22.7335, -21.4512, -20.1922, -19.0179, -17.7446, -16.5558,
    -15.3904, -14.126, -12.9462, -11.6673, -10.4118, -9.24087, -7.97091,
    -6.78556, -5.50115, -4.24013, -3.06371, -1.78823, -0.597365, 0.570117,
    1.83666, 3.0186, 4.2996, 5.55721, 6.73021, 8.00228, 9.18974,
    10.3538, 11.6169, 12.7955, 14.0731, 15.266, 16.4356, 17.7043,
    18.8883, 20.1714, 21.4312, 22.6063, 23.8804, 25.07, 26.2362,
    27.5014, 28.6821, 30.


    7 to 8, corresponding to f[x, 7] is one such interval. Since we don't sample between those values, we never see f[x,7] == 1 and the resulting plot is zero everywhere.






    share|improve this answer










    $endgroup$













    • $begingroup$
      But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
      $endgroup$
      – Nasser
      Sep 30 at 4:48







    • 4




      $begingroup$
      @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
      $endgroup$
      – Lukas Lang
      Sep 30 at 12:45













    7















    7











    7







    $begingroup$

    Your plots aren't empty: they have a line along the x axis.



    Plot uses PlotPoints -> 50 by default, and since you go from -30 to 30, there will be some $n$ to $n+1$ intervals that don't get sampled:



    In[66]:= Reap[
    Plot[x, x, -30, 30, MaxRecursion -> 0,
    EvaluationMonitor :> Sow[x]];]

    Out[66]= Null, -30., -28.8223, -27.5455, -26.3533, -25.1845,
    -23.9167, -22.7335, -21.4512, -20.1922, -19.0179, -17.7446, -16.5558,
    -15.3904, -14.126, -12.9462, -11.6673, -10.4118, -9.24087, -7.97091,
    -6.78556, -5.50115, -4.24013, -3.06371, -1.78823, -0.597365, 0.570117,
    1.83666, 3.0186, 4.2996, 5.55721, 6.73021, 8.00228, 9.18974,
    10.3538, 11.6169, 12.7955, 14.0731, 15.266, 16.4356, 17.7043,
    18.8883, 20.1714, 21.4312, 22.6063, 23.8804, 25.07, 26.2362,
    27.5014, 28.6821, 30.


    7 to 8, corresponding to f[x, 7] is one such interval. Since we don't sample between those values, we never see f[x,7] == 1 and the resulting plot is zero everywhere.






    share|improve this answer










    $endgroup$



    Your plots aren't empty: they have a line along the x axis.



    Plot uses PlotPoints -> 50 by default, and since you go from -30 to 30, there will be some $n$ to $n+1$ intervals that don't get sampled:



    In[66]:= Reap[
    Plot[x, x, -30, 30, MaxRecursion -> 0,
    EvaluationMonitor :> Sow[x]];]

    Out[66]= Null, -30., -28.8223, -27.5455, -26.3533, -25.1845,
    -23.9167, -22.7335, -21.4512, -20.1922, -19.0179, -17.7446, -16.5558,
    -15.3904, -14.126, -12.9462, -11.6673, -10.4118, -9.24087, -7.97091,
    -6.78556, -5.50115, -4.24013, -3.06371, -1.78823, -0.597365, 0.570117,
    1.83666, 3.0186, 4.2996, 5.55721, 6.73021, 8.00228, 9.18974,
    10.3538, 11.6169, 12.7955, 14.0731, 15.266, 16.4356, 17.7043,
    18.8883, 20.1714, 21.4312, 22.6063, 23.8804, 25.07, 26.2362,
    27.5014, 28.6821, 30.


    7 to 8, corresponding to f[x, 7] is one such interval. Since we don't sample between those values, we never see f[x,7] == 1 and the resulting plot is zero everywhere.







    share|improve this answer













    share|improve this answer




    share|improve this answer










    answered Sep 30 at 4:23









    Brett ChampionBrett Champion

    18.4k2 gold badges52 silver badges118 bronze badges




    18.4k2 gold badges52 silver badges118 bronze badges














    • $begingroup$
      But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
      $endgroup$
      – Nasser
      Sep 30 at 4:48







    • 4




      $begingroup$
      @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
      $endgroup$
      – Lukas Lang
      Sep 30 at 12:45
















    • $begingroup$
      But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
      $endgroup$
      – Nasser
      Sep 30 at 4:48







    • 4




      $begingroup$
      @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
      $endgroup$
      – Lukas Lang
      Sep 30 at 12:45















    $begingroup$
    But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
    $endgroup$
    – Nasser
    Sep 30 at 4:48





    $begingroup$
    But this does not really explain why it shows the pulse when using other values of n for same range and same plot points? For example f[x, 2] it misses it, but f[x, 8] it does not. Same range. So is it hit and miss type of thing? ps. I know the plot is not empty, (I see the line y=0 there) I was lazy :) and just meant the pulse itself is not showing. I should be more clear.
    $endgroup$
    – Nasser
    Sep 30 at 4:48





    4




    4




    $begingroup$
    @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
    $endgroup$
    – Lukas Lang
    Sep 30 at 12:45




    $begingroup$
    @Nasser Essentially, you see the pulse if the initial set of sampling points of Plot contains the pulse (if not, Plot has no reason to increase the sampling). If you look at the sampled points, you'll see that there are no points in $[2,3],[7,8],[13,14],[19,20],[24,25],[29,30]$, so if the pulse is in any of those intervals, Plot will miss it, otherwise it will find it
    $endgroup$
    – Lukas Lang
    Sep 30 at 12:45













    6

















    $begingroup$

    Brett's answer explains the why.



    To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) :



    f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]

    Plot[f[x, 7], x, -30, 30,
    PlotPoints -> 50, 7,
    PlotStyle -> CapForm["Butt"],
    Axes -> False, Frame -> True,
    PlotRange -> -1, 1,
    PlotRangePadding -> Scaled[.05]]


    enter image description here



    Add Exclusions -> None to get the vertical portions:



    enter image description here






    share|improve this answer












    $endgroup$


















      6

















      $begingroup$

      Brett's answer explains the why.



      To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) :



      f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]

      Plot[f[x, 7], x, -30, 30,
      PlotPoints -> 50, 7,
      PlotStyle -> CapForm["Butt"],
      Axes -> False, Frame -> True,
      PlotRange -> -1, 1,
      PlotRangePadding -> Scaled[.05]]


      enter image description here



      Add Exclusions -> None to get the vertical portions:



      enter image description here






      share|improve this answer












      $endgroup$
















        6















        6











        6







        $begingroup$

        Brett's answer explains the why.



        To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) :



        f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]

        Plot[f[x, 7], x, -30, 30,
        PlotPoints -> 50, 7,
        PlotStyle -> CapForm["Butt"],
        Axes -> False, Frame -> True,
        PlotRange -> -1, 1,
        PlotRangePadding -> Scaled[.05]]


        enter image description here



        Add Exclusions -> None to get the vertical portions:



        enter image description here






        share|improve this answer












        $endgroup$



        Brett's answer explains the why.



        To force sampling at specified points you can use an undocumented form of PlotPoints (see this answer by Ullrich Neumann) :



        f[x_, n_] := Piecewise[1, n < x < n + 1, 0, True]

        Plot[f[x, 7], x, -30, 30,
        PlotPoints -> 50, 7,
        PlotStyle -> CapForm["Butt"],
        Axes -> False, Frame -> True,
        PlotRange -> -1, 1,
        PlotRangePadding -> Scaled[.05]]


        enter image description here



        Add Exclusions -> None to get the vertical portions:



        enter image description here







        share|improve this answer















        share|improve this answer




        share|improve this answer








        edited Sep 30 at 15:34

























        answered Sep 30 at 15:28









        kglrkglr

        229k10 gold badges259 silver badges523 bronze badges




        229k10 gold badges259 silver badges523 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207091%2fplot-sampling-and-why-it-does-not-display-for-some-ranges%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?