Skip to content

Image Discussion  #120

Open
Open
@ghost

Description

This is mostly for Alex and Sean to discuss but I thought I would create it here since it seems like it would be a good place for it. There is a small issue with the way borders work with filling with the new method Alex provided. In the current preamble there is a line:

\pgfplotsset{firstcurvestyle/.style={color=firstcolor,mark=none,thick,{Kite}-{Kite},solid}}

which was updated to add the ability to fill without needing to use 2 separate addplot commands (the color information was added in here instead, before it was defined in the addplot function using {\coloronefill} which was set to: blue!15!white) as shown below.

\pgfplotsset{firstcurvestyle/.style={color=firstcolor,mark=none,thick,{Kite}-{Kite},solid,fill=firstcolor!50,fill=none}}

Now, it is possible to convert an image like this one (from sec_improper_integration: img_impint1a):

\begin{tikzpicture}

\begin{axis}[
axis on top,
xtick={1,5,10},
ymin=-.1,ymax=1.1,
xmin=-1,xmax=11
]

\addplot [{\coloronefill},fill={\coloronefill}] coordinates {(1.,1.)(1.5,0.4444)(2.,0.25)(2.5,0.16)(3.,0.1111)(3.5,0.08163)(4.,0.0625)(4.5,0.04938)(5.,0.04)(5.5,0.03306)(6.,0.02778)(6.5,0.02367)(7.,0.02041)(7.5,0.01778)(8.,0.01563)(8.5,0.01384)(9.,0.01235)(9.5,0.01108)(10.,0.01)(10.5,0.009)} -- (axis cs:10.5,0)--(axis cs:1,0)--cycle;
\addplot [{\colorone},thick,smooth] coordinates {(1.,1.)(1.5,0.4444)(2.,0.25)(2.5,0.16)(3.,0.1111)(3.5,0.08163)(4.,0.0625)(4.5,0.04938)(5.,0.04)(5.5,0.03306)(6.,0.02778)(6.5,0.02367)(7.,0.02041)(7.5,0.01778)(8.,0.01563)(8.5,0.01384)(9.,0.01235)(9.5,0.01108)(10.,0.01)(10.5,0.009)};

\draw (axis cs:5,.75) node {\scriptsize $\ds f(x)=\frac{1}{x^2}$};

\end{axis}

\end{tikzpicture}

Which looks like this (matching the original in the book):
image

into:

\begin{tikzpicture}

\begin{axis}[
axis on top,
xtick={1,5,10},
ymin=-.1,ymax=1.1,
xmin=-1,xmax=11
]

\addplot+ [fill,smooth] coordinates {(1.,1.)(1.5,0.4444)(2.,0.25)(2.5,0.16)(3.,0.1111)(3.5,0.08163)(4.,0.0625)(4.5,0.04938)(5.,0.04)(5.5,0.03306)(6.,0.02778)(6.5,0.02367)(7.,0.02041)(7.5,0.01778)(8.,0.01563)(8.5,0.01384)(9.,0.01235)(9.5,0.01108)(10.,0.01)(10.5,0.009)} -- (axis cs:10.5,0)--(axis cs:1,0)--cycle;

\draw (axis cs:5,.75) node {\scriptsize $\ds f(x)=\frac{1}{x^2}$};

\end{axis}

\end{tikzpicture}

Which now looks like this image below.
image

Notice that there is a border around the fill. I believe the issue might lie in the cycle code at the end of the image such as:

-- (axis cs:10.5,0)--(axis cs:1,0)--cycle

in the above case or

\closedcycle

in other cases that appear in chapter 5.

As an aside for Sean (since we are on the topic). We have not discussed it but notice that the image above is using coordinates to define its curve when the function is obvious. In chapter 5 the images are updated to use functions and samples instead. I can easily convert the image above to use that form in most cases I have seen (I have kind of done some already in chapter 6, couldn't resist). The example above when converted will be:

\begin{tikzpicture}

\begin{axis}[
axis on top,
xtick={1,5,10},
ymin=-.1,ymax=1.1,
xmin=-1,xmax=11
]

\addplot [{\coloronefill},fill={\coloronefill},domain=1:10.5,samples=100] {1/(x^2)} -- (axis cs:10.5,0) -- (axis cs:1,0) -- cycle;
\addplot [firstcurvestyle,-,domain=1:10.5,samples=100] {1/(x^2)};

\draw (axis cs:5,.75) node {\scriptsize $\ds f(x)=\frac{1}{x^2}$};

\end{axis}

\end{tikzpicture}

and if using the updated command I can shorten it to the code below.

\begin{tikzpicture}

\begin{axis}[
axis on top,
xtick={1,5,10},
ymin=-.1,ymax=1.1,
xmin=-1,xmax=11
]

\addplot+ [fill,domain=1:10.5,samples=100] {1/(x^2)} \closedcycle;

\draw (axis cs:5,.75) node {\scriptsize $\ds f(x)=\frac{1}{x^2}$};

\end{axis}

\end{tikzpicture}

This is much shorter and definitely something I want to do. Of course the above only works if we fix the bordering issue and I would have to go back through the images in chapter 5 and some of 6 to support the change.

My question is do you want me making those kinds of changes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions