Plotting a bump functionplotting two time series with boundsGrouped bar chartHow do i get the x axis on top...
Can you say "leftside right"?
Are all power cords made equal?
Linearity Assumption
Is the tritone (A4 / d5) still banned in Roman Catholic music?
Is the percentage symbol a constant?
If we can’t finish all tasks, does this mean we are doing Scrum wrong?
How do I avoid the "chosen hero" feeling?
Minimum Viable Product for RTS game?
Tikz: Perpendicular FROM a line
Why is Shelob considered evil?
Did ancient Germans take pride in leaving the land untouched?
two subject complements in passive form?
Why does my printer create notches on the Y surface?
Why don't you get burned by the wood benches in a sauna?
Have any astronauts or cosmonauts died in space?
Is there any way to play D&D without a DM?
Is it possible to narrate a novel in a faux-historical style without alienating the reader?
Does Plato's "Ring of Gyges" have a corrupting influence on its wearer?
Is it possible to detect 100% of SQLi with a simple regex?
How to deal with an underperforming subordinate?
Words of Worship and Nefarious Lich
Finding the index of a specific element in a list
What is an efficient way to digitize a family photo collection?
Third wheel character
Plotting a bump function
plotting two time series with boundsGrouped bar chartHow do i get the x axis on top but keep a line on the bottomTikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?How to hide empty (value 0) ybars with pgfplots?Show mark labels near marks and not centered in ybar interaval graphpgfplots: percentage in matrix plotCenter the axes in the coordinate originaxis ticks labels are unreadable too close
I would like to plot a bump function in a similar way as its done in Loring W. Tu's Book 'An introduction to Manifolds' (page 129, fig. 13.4), however it never quite works the way I want. Here is my MWE:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:0, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=0:1, thick, label={x}]
plot (x, { exp( -1/x)/(exp (-1/x)+exp(1/(x-1))) });
addplot[black, thick, samples=100, smooth, domain=1:2]
plot (x, {1} );
end{axis}
end{tikzpicture}
end{document}
My main problem with this result is, that the "plateau" is already attained before x=1, which really doesn't look like it's right. Changing sample sizes to higher than 100 will immediately yield dimension errors. Any tips?
tikz-pgf pgfplots
New contributor
add a comment |
I would like to plot a bump function in a similar way as its done in Loring W. Tu's Book 'An introduction to Manifolds' (page 129, fig. 13.4), however it never quite works the way I want. Here is my MWE:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:0, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=0:1, thick, label={x}]
plot (x, { exp( -1/x)/(exp (-1/x)+exp(1/(x-1))) });
addplot[black, thick, samples=100, smooth, domain=1:2]
plot (x, {1} );
end{axis}
end{tikzpicture}
end{document}
My main problem with this result is, that the "plateau" is already attained before x=1, which really doesn't look like it's right. Changing sample sizes to higher than 100 will immediately yield dimension errors. Any tips?
tikz-pgf pgfplots
New contributor
add a comment |
I would like to plot a bump function in a similar way as its done in Loring W. Tu's Book 'An introduction to Manifolds' (page 129, fig. 13.4), however it never quite works the way I want. Here is my MWE:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:0, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=0:1, thick, label={x}]
plot (x, { exp( -1/x)/(exp (-1/x)+exp(1/(x-1))) });
addplot[black, thick, samples=100, smooth, domain=1:2]
plot (x, {1} );
end{axis}
end{tikzpicture}
end{document}
My main problem with this result is, that the "plateau" is already attained before x=1, which really doesn't look like it's right. Changing sample sizes to higher than 100 will immediately yield dimension errors. Any tips?
tikz-pgf pgfplots
New contributor
I would like to plot a bump function in a similar way as its done in Loring W. Tu's Book 'An introduction to Manifolds' (page 129, fig. 13.4), however it never quite works the way I want. Here is my MWE:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:0, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=0:1, thick, label={x}]
plot (x, { exp( -1/x)/(exp (-1/x)+exp(1/(x-1))) });
addplot[black, thick, samples=100, smooth, domain=1:2]
plot (x, {1} );
end{axis}
end{tikzpicture}
end{document}
My main problem with this result is, that the "plateau" is already attained before x=1, which really doesn't look like it's right. Changing sample sizes to higher than 100 will immediately yield dimension errors. Any tips?
tikz-pgf pgfplots
tikz-pgf pgfplots
New contributor
New contributor
New contributor
asked 3 hours ago
rhodeltarhodelta
132
132
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Welcome to TeX.SE! I do not have that book but often people use tanh
for that.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(5*(x-0.5)))});
end{axis}
end{tikzpicture}
end{document}
Of course, you can vary the width of the step by playing with the prefactor, which is 5 above.
documentclass[border=10pt,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
foreach X in {2,2.2,...,6,5.8,5.6,...,2.2}
{begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40,
title={$f(x)=left[1+tanhbigl(
pgfmathprintnumber[precision=1,fixed,zerofill]{X}(x-1/2)bigr)right]/2$}]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(X*(x-0.5)))});
end{axis}
end{tikzpicture}}
end{document}
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
add a comment |
The plots in proferred answers do not look like what I understand to be a bump function; rather, the plots of the derivatives of the indicated functions would be bump functions. The following directly produces a bump function plot, with support the interval $[-1,1]$:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thin},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=1.2, ymin=-0.2, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-0.2:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:-1, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=-1:1, thick, label={x}]
plot (x, {exp(1-1/(1-x^2)});
addplot[black, thick, samples=100, smooth, domain=1:1.2]
plot (x, {0} );
end{axis}
end{tikzpicture}
end{document}
(I'm unsure how to avoid the apparent gap in the graph immediately to the right of $x=-1$.)
The gap will disappear once you plotaddplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.
– marmot
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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/3.0/"u003ecc by-sa 3.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
});
}
});
rhodelta is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476350%2fplotting-a-bump-function%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
Welcome to TeX.SE! I do not have that book but often people use tanh
for that.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(5*(x-0.5)))});
end{axis}
end{tikzpicture}
end{document}
Of course, you can vary the width of the step by playing with the prefactor, which is 5 above.
documentclass[border=10pt,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
foreach X in {2,2.2,...,6,5.8,5.6,...,2.2}
{begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40,
title={$f(x)=left[1+tanhbigl(
pgfmathprintnumber[precision=1,fixed,zerofill]{X}(x-1/2)bigr)right]/2$}]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(X*(x-0.5)))});
end{axis}
end{tikzpicture}}
end{document}
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
add a comment |
Welcome to TeX.SE! I do not have that book but often people use tanh
for that.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(5*(x-0.5)))});
end{axis}
end{tikzpicture}
end{document}
Of course, you can vary the width of the step by playing with the prefactor, which is 5 above.
documentclass[border=10pt,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
foreach X in {2,2.2,...,6,5.8,5.6,...,2.2}
{begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40,
title={$f(x)=left[1+tanhbigl(
pgfmathprintnumber[precision=1,fixed,zerofill]{X}(x-1/2)bigr)right]/2$}]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(X*(x-0.5)))});
end{axis}
end{tikzpicture}}
end{document}
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
add a comment |
Welcome to TeX.SE! I do not have that book but often people use tanh
for that.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(5*(x-0.5)))});
end{axis}
end{tikzpicture}
end{document}
Of course, you can vary the width of the step by playing with the prefactor, which is 5 above.
documentclass[border=10pt,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
foreach X in {2,2.2,...,6,5.8,5.6,...,2.2}
{begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40,
title={$f(x)=left[1+tanhbigl(
pgfmathprintnumber[precision=1,fixed,zerofill]{X}(x-1/2)bigr)right]/2$}]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(X*(x-0.5)))});
end{axis}
end{tikzpicture}}
end{document}
Welcome to TeX.SE! I do not have that book but often people use tanh
for that.
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(5*(x-0.5)))});
end{axis}
end{tikzpicture}
end{document}
Of course, you can vary the width of the step by playing with the prefactor, which is 5 above.
documentclass[border=10pt,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{%
every x tick/.style={black, thick},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
foreach X in {2,2.2,...,6,5.8,5.6,...,2.2}
{begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=2, ymin=-0.7, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-1.5:1.2,
axis x line=center, axis y line= center,
samples=40,
title={$f(x)=left[1+tanhbigl(
pgfmathprintnumber[precision=1,fixed,zerofill]{X}(x-1/2)bigr)right]/2$}]
addplot[black, samples=100, smooth, domain=-1.2:2, thick]
plot (x, {0.5*(1+tanh(X*(x-0.5)))});
end{axis}
end{tikzpicture}}
end{document}
edited 2 hours ago
answered 3 hours ago
marmotmarmot
103k4121233
103k4121233
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
add a comment |
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
great answer, exactly what I needed thanks a lot!
– rhodelta
3 hours ago
1
1
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
@ArtificialStupidity Well, fixed it, but do you think that is important here?
– marmot
2 hours ago
1
1
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
Yes. It is important for me. :-) Thank you for fixing!
– Artificial Stupidity
2 hours ago
add a comment |
The plots in proferred answers do not look like what I understand to be a bump function; rather, the plots of the derivatives of the indicated functions would be bump functions. The following directly produces a bump function plot, with support the interval $[-1,1]$:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thin},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=1.2, ymin=-0.2, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-0.2:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:-1, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=-1:1, thick, label={x}]
plot (x, {exp(1-1/(1-x^2)});
addplot[black, thick, samples=100, smooth, domain=1:1.2]
plot (x, {0} );
end{axis}
end{tikzpicture}
end{document}
(I'm unsure how to avoid the apparent gap in the graph immediately to the right of $x=-1$.)
The gap will disappear once you plotaddplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.
– marmot
2 hours ago
add a comment |
The plots in proferred answers do not look like what I understand to be a bump function; rather, the plots of the derivatives of the indicated functions would be bump functions. The following directly produces a bump function plot, with support the interval $[-1,1]$:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thin},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=1.2, ymin=-0.2, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-0.2:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:-1, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=-1:1, thick, label={x}]
plot (x, {exp(1-1/(1-x^2)});
addplot[black, thick, samples=100, smooth, domain=1:1.2]
plot (x, {0} );
end{axis}
end{tikzpicture}
end{document}
(I'm unsure how to avoid the apparent gap in the graph immediately to the right of $x=-1$.)
The gap will disappear once you plotaddplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.
– marmot
2 hours ago
add a comment |
The plots in proferred answers do not look like what I understand to be a bump function; rather, the plots of the derivatives of the indicated functions would be bump functions. The following directly produces a bump function plot, with support the interval $[-1,1]$:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thin},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=1.2, ymin=-0.2, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-0.2:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:-1, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=-1:1, thick, label={x}]
plot (x, {exp(1-1/(1-x^2)});
addplot[black, thick, samples=100, smooth, domain=1:1.2]
plot (x, {0} );
end{axis}
end{tikzpicture}
end{document}
(I'm unsure how to avoid the apparent gap in the graph immediately to the right of $x=-1$.)
The plots in proferred answers do not look like what I understand to be a bump function; rather, the plots of the derivatives of the indicated functions would be bump functions. The following directly produces a bump function plot, with support the interval $[-1,1]$:
documentclass[border=10pt]{standalone}
usepackage{pgfplots}
usepackage{tikz}
pgfplotsset{%
every x tick/.style={black, thin},
every y tick/.style={black, thick},
every tick label/.append style = {font=footnotesize},
every axis label/.append style = {font=footnotesize},
compat=1.12
}
begin{document}
begin{tikzpicture}
begin{axis}[xmin=-1.2, xmax=1.2, ymin=-0.2, ymax=1.2,
xtick = {-1,0,1}, ytick = { 1},
scale=0.4, restrict y to domain=-0.2:1.2,
axis x line=center, axis y line= center,
samples=40]
addplot[black, samples=100, smooth, domain=-1.2:-1, thick]
plot (x, { 0 });
addplot[black, samples=100, smooth, domain=-1:1, thick, label={x}]
plot (x, {exp(1-1/(1-x^2)});
addplot[black, thick, samples=100, smooth, domain=1:1.2]
plot (x, {0} );
end{axis}
end{tikzpicture}
end{document}
(I'm unsure how to avoid the apparent gap in the graph immediately to the right of $x=-1$.)
answered 2 hours ago
murraymurray
2,1571031
2,1571031
The gap will disappear once you plotaddplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.
– marmot
2 hours ago
add a comment |
The gap will disappear once you plotaddplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.
– marmot
2 hours ago
The gap will disappear once you plot
addplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.– marmot
2 hours ago
The gap will disappear once you plot
addplot[black, samples=101, smooth, domain=-1.2:1.2, thick, label={x}] plot (x, {ifthenelse(abs(x)>1,0,exp(1-1/(1-x^2))});
instead of three plots.– marmot
2 hours ago
add a comment |
rhodelta is a new contributor. Be nice, and check out our Code of Conduct.
rhodelta is a new contributor. Be nice, and check out our Code of Conduct.
rhodelta is a new contributor. Be nice, and check out our Code of Conduct.
rhodelta is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX 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.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476350%2fplotting-a-bump-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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