So as not to make this an XY problem, let me start with what I'm trying to accomplish here. I've been teaching a calculus course, and introducing my students to limits. I've been avoiding epsilons and deltas, but I've been showing them visually what a limit looks like, essentially teaching them the epsilon-delta definition through pictures. For example, this kind of thing:

Demonstration of a Limit

I always use yellow!40 for the bounds in the codomain, and red!40 for the bounds in the domain.

I want to create two summary tables involving the various types of limits (finite, infinite, one-sided, two-sided, etc), and have little Tikz pictures that remind them visually what these things look like. One table is for the codomain (i.e. whether the limit is finite, infinity, or negative infinity), and the next will be the domain (finite two-sided, finite from the left, the right, infinity, and -infinity). I'm currently doing the first table.

For a finite limit, I have the following Tikz picture:

Epsilon band, with fading




\fill[fill=yellow!40, path fading = east] (0, 0) rectangle (4, 2);
\fill[fill=yellow!40, path fading = west] (0, 0) rectangle (-4, 2);

\clip (0, 0) rectangle (4, 2);
\draw[line width=0mm, dashed, path fading = east] (-4, 2) -- (4, 2);
\draw[line width=0mm, dashed, path fading = east] (-4, 0) -- (4, 0);
\draw[line width=0mm, dashed, path fading = east] (-4, 1) -- (4, 1);

\clip (0, 0) rectangle (-4, 2);
\draw[line width=0mm, dashed, path fading = west] (-4, 2) -- (4, 2);
\draw[line width=0mm, dashed, path fading = west] (-4, 0) -- (4, 0);
\draw[line width=0mm, dashed, path fading = west] (-4, 1) -- (4, 1);



Note the fading, to denote that the region continues unboundedly. I would now like something for the infinite limits, where the yellow region continues indefinitely not just east and west, but also either north or south as well. I would also like the fading to reflect this. Plus, it would be good if the size of the picture can be standardised with the previous one (i.e. take place in a box of dimensions 8 x 2).

I was considering doing a radial fading, starting at (0, 0), and clipping to the 8 x 2 box, but this will be a circular fade that will end up clipping rather than properly fading out. Is there a way to make this using some kind of elliptical fade? Note: I would still like a fading dashed line on the (relatively) unfaded edge.

(By the way, I am learning Tikz as I go. I am definitely not strong with it yet.)

  • I think opacity can be used instead of fading. Anyway, the figure is nice, pedagogically!
    – Black Mild
    Jan 25 at 4:48
  • Unrelated: line width=0mm does not make sense. Do not use the minimal class. tex.stackexchange.com/questions/42114/… Jan 25 at 21:19
  • 1
    @hpekristiansen line width=0pt is perfect. Extract from PDF references "A line width of 0 shall denote the thinnest line that can be rendered at device resolution: 1 device pixel wide." Jan 25 at 22:20

2 Answers 2

\documentclass[tikz, border=1cm]{standalone}

\begin{tikzfadingfrompicture}[name=myfading horizontal]
\draw[left color=transparent!100, right color=transparent!100, middle color=transparent!0] (-4,-2) rectangle (4,2);

\begin{tikzfadingfrompicture}[name=myfading radial]
\draw[inner color=transparent!0, outer color=transparent!100] (-4,-1.5) rectangle (4,1.5);

\path[scope fading=myfading horizontal, fit fading=false]  (-4,-1) rectangle (4,1);
\fill[yellow] (-4,-1) rectangle (4,1);
\draw[dashed] (-4, -1) -- (4, -1) (-4, 0) -- (4, 0) (-4, 1) -- (4, 1);
\path[scope fading=myfading radial, fit fading=false]  (-4,-1) rectangle (4,1);
\fill[yellow] (-4,-1) rectangle (4,1);
\draw[dashed] (-4, -1) -- (4, -1) (-4, 0) -- (4, 0) (-4, 1) -- (4, 1);

Faded yellow rectangles


Pedagogically, the simple the better! I avoid to use fading, and dashed lines. I choose Asymptote due to convenient commands size(), unitsize(), and for high customization. The code is automatic with random left and right limits of the vertical strip around the point (a,f(a)). The option opacity(.5) makes the colors red and yellow mixing at the intersection region that is expected.

An animation is nice in this situation. I will add later!

enter image description here

// http://asymptote.ualberta.ca/
import graph;
real f(real x){return x^3;}
real finv(real y){return cbrt(y);}
pair A=(-1,-1),B=(3,3);
real a=1;
pair M=(a,f(a));
path pf=graph(f,A.x,B.x);
real ap=a+.3*unitrand(),am=a-.35*unitrand();

With srand(10); added

enter image description here

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.