Problem With Plotting Square Root in TIKZ Announcing the arrival of Valued Associate #679:...

Flight departed from the gate 5 min before scheduled departure time. Refund options

Weaponising the Grasp-at-a-Distance spell

Is there a verb for listening stealthily?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

Who's this lady in the war room?

Is it possible to intall libXft.so.2 on WSL?

Is there a right way of implementing a T flip flop in verilog wrt using reset signal?

Was the pager message from Nick Fury to Captain Marvel unnecessary?

New Order #6: Easter Egg

Centre cell vertically in tabularx across multiple multiline rows

Magento 2 - Add additional attributes in register

Can anyone explain what's the meaning of this in the new Game of Thrones opening animations?

Maximum rotation made by a symmetric positive definite matrix?

How do I say "this must not happen"?

Do British people often use the word lightning conductor?

Noise in Eigenvalues plot

Magento 2 Editing phtml files in Production Mode

How did 'ликвиди́ровать' semantically shift to mean 'abolish' and 'destroy, kill'?

Changing order of draw operation in PGFPlots

How does Billy Russo acquire his 'Jigsaw' mask?

Can I feed enough spin up electron to a black hole to affect it's angular momentum?

Asymmetric or symmetric - which makes sense in this scenario?

How do you cope with tons of web fonts when copying and pasting from web pages?

No invitation for tourist visa but I want to visit



Problem With Plotting Square Root in TIKZ



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Paragraph ended before tikz@intersect@path@names@parse was completeRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?pgfplots markers and lines on different layersTikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?TikZ/ERD: node (=Entity) label on the insideTikZ: Drawing an arc from an intersection to an intersectionLine up nested tikz enviroments or how to get rid of themProblems with nested TikZpicturesTikZ: Place different elements of a same path on various layers












2















Does anyone know why this plot looks funny between 0 and 1 ? The same will happen if I try to plot the cube root function. Please advise. I am trying to avoid using pgfplots package.



documentclass{article}
usepackage{tikz}

begin{document}
begin{tikzpicture}[scale=.6,cap=round]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x/xtext in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{scriptsize $xtext$};
foreach y/ytext in {-3, -2, -1, 1, 2, 3, 4, 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{scriptsize $ytext$};
%filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{scriptsize $(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{scriptsize $(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}


end{document}


enter image description here










share|improve this question

























  • TikZ loads the pgf package as it builds upon that.

    – Skillmon
    Oct 26 '18 at 16:56











  • I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

    – MathScholar
    Oct 26 '18 at 16:59











  • A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

    – Ruixi Zhang
    Oct 27 '18 at 1:13
















2















Does anyone know why this plot looks funny between 0 and 1 ? The same will happen if I try to plot the cube root function. Please advise. I am trying to avoid using pgfplots package.



documentclass{article}
usepackage{tikz}

begin{document}
begin{tikzpicture}[scale=.6,cap=round]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x/xtext in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{scriptsize $xtext$};
foreach y/ytext in {-3, -2, -1, 1, 2, 3, 4, 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{scriptsize $ytext$};
%filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{scriptsize $(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{scriptsize $(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}


end{document}


enter image description here










share|improve this question

























  • TikZ loads the pgf package as it builds upon that.

    – Skillmon
    Oct 26 '18 at 16:56











  • I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

    – MathScholar
    Oct 26 '18 at 16:59











  • A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

    – Ruixi Zhang
    Oct 27 '18 at 1:13














2












2








2








Does anyone know why this plot looks funny between 0 and 1 ? The same will happen if I try to plot the cube root function. Please advise. I am trying to avoid using pgfplots package.



documentclass{article}
usepackage{tikz}

begin{document}
begin{tikzpicture}[scale=.6,cap=round]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x/xtext in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{scriptsize $xtext$};
foreach y/ytext in {-3, -2, -1, 1, 2, 3, 4, 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{scriptsize $ytext$};
%filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{scriptsize $(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{scriptsize $(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}


end{document}


enter image description here










share|improve this question
















Does anyone know why this plot looks funny between 0 and 1 ? The same will happen if I try to plot the cube root function. Please advise. I am trying to avoid using pgfplots package.



documentclass{article}
usepackage{tikz}

begin{document}
begin{tikzpicture}[scale=.6,cap=round]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x/xtext in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{scriptsize $xtext$};
foreach y/ytext in {-3, -2, -1, 1, 2, 3, 4, 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{scriptsize $ytext$};
%filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{scriptsize $(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{scriptsize $(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {scriptsize
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}


end{document}


enter image description here







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 17 mins ago









JouleV

14.9k22666




14.9k22666










asked Oct 26 '18 at 16:44









MathScholarMathScholar

1,10529




1,10529













  • TikZ loads the pgf package as it builds upon that.

    – Skillmon
    Oct 26 '18 at 16:56











  • I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

    – MathScholar
    Oct 26 '18 at 16:59











  • A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

    – Ruixi Zhang
    Oct 27 '18 at 1:13



















  • TikZ loads the pgf package as it builds upon that.

    – Skillmon
    Oct 26 '18 at 16:56











  • I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

    – MathScholar
    Oct 26 '18 at 16:59











  • A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

    – Ruixi Zhang
    Oct 27 '18 at 1:13

















TikZ loads the pgf package as it builds upon that.

– Skillmon
Oct 26 '18 at 16:56





TikZ loads the pgf package as it builds upon that.

– Skillmon
Oct 26 '18 at 16:56













I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

– MathScholar
Oct 26 '18 at 16:59





I suppose I mean without using pgfplots. What is the advantage? Also I will try to rewrite this function in terms of logarithms to see if that makes a difference.

– MathScholar
Oct 26 '18 at 16:59













A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

– Ruixi Zhang
Oct 27 '18 at 1:13





A much, much simpler solution without increasing sampling points is draw[domain=0:3.162278,smooth,variable=x,blue,thick,->] plot (x^2,x); I always find re-parameterizing the function produces better looking results.

– Ruixi Zhang
Oct 27 '18 at 1:13










1 Answer
1






active

oldest

votes


















2














Because your sample is not large enough: by default it is 25 points. With a sample of 200 points, this works.



Edit: Modification of the sample. Many thanks to Skillmon for having the idea to modify the sample and to @marmot for giving a simple and effective example.



Your foreach loops do not need to have two variables. Only one is enough, for the displayed text to be smaller, there is the key font=scriptsize.



Edit 2:
And to avoid repeating this for each node, just do it with every node/.style={font=scriptsize} to overwrite the pre-existing style or every node/append style={font=scriptsize} to simply add this style to the pre-existing style without overwriting it.



documentclass{article}
usepackage{tikz,pgfplots}
begin{document}
begin{tikzpicture}[scale=.6,cap=round,every node/.style={font=scriptsize}]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x in {1, ..., 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{ x};
foreach y in {-3,..., 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{ y};

filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{$(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{$(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->,samples at={0,0.05,...,1,1.5,...,10.5}] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}
end{document}


plot






share|improve this answer





















  • 1





    I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

    – Skillmon
    Oct 26 '18 at 17:13











  • @Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

    – AndréC
    Oct 26 '18 at 17:21











  • @Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

    – MathScholar
    Oct 26 '18 at 17:23








  • 1





    Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

    – Skillmon
    Oct 26 '18 at 17:24








  • 3





    @Skillmon samples at={0,0.05,...,1,1.5,...,10}.

    – marmot
    Oct 26 '18 at 17:53












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456928%2fproblem-with-plotting-square-root-in-tikz%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Because your sample is not large enough: by default it is 25 points. With a sample of 200 points, this works.



Edit: Modification of the sample. Many thanks to Skillmon for having the idea to modify the sample and to @marmot for giving a simple and effective example.



Your foreach loops do not need to have two variables. Only one is enough, for the displayed text to be smaller, there is the key font=scriptsize.



Edit 2:
And to avoid repeating this for each node, just do it with every node/.style={font=scriptsize} to overwrite the pre-existing style or every node/append style={font=scriptsize} to simply add this style to the pre-existing style without overwriting it.



documentclass{article}
usepackage{tikz,pgfplots}
begin{document}
begin{tikzpicture}[scale=.6,cap=round,every node/.style={font=scriptsize}]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x in {1, ..., 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{ x};
foreach y in {-3,..., 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{ y};

filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{$(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{$(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->,samples at={0,0.05,...,1,1.5,...,10.5}] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}
end{document}


plot






share|improve this answer





















  • 1





    I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

    – Skillmon
    Oct 26 '18 at 17:13











  • @Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

    – AndréC
    Oct 26 '18 at 17:21











  • @Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

    – MathScholar
    Oct 26 '18 at 17:23








  • 1





    Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

    – Skillmon
    Oct 26 '18 at 17:24








  • 3





    @Skillmon samples at={0,0.05,...,1,1.5,...,10}.

    – marmot
    Oct 26 '18 at 17:53
















2














Because your sample is not large enough: by default it is 25 points. With a sample of 200 points, this works.



Edit: Modification of the sample. Many thanks to Skillmon for having the idea to modify the sample and to @marmot for giving a simple and effective example.



Your foreach loops do not need to have two variables. Only one is enough, for the displayed text to be smaller, there is the key font=scriptsize.



Edit 2:
And to avoid repeating this for each node, just do it with every node/.style={font=scriptsize} to overwrite the pre-existing style or every node/append style={font=scriptsize} to simply add this style to the pre-existing style without overwriting it.



documentclass{article}
usepackage{tikz,pgfplots}
begin{document}
begin{tikzpicture}[scale=.6,cap=round,every node/.style={font=scriptsize}]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x in {1, ..., 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{ x};
foreach y in {-3,..., 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{ y};

filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{$(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{$(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->,samples at={0,0.05,...,1,1.5,...,10.5}] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}
end{document}


plot






share|improve this answer





















  • 1





    I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

    – Skillmon
    Oct 26 '18 at 17:13











  • @Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

    – AndréC
    Oct 26 '18 at 17:21











  • @Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

    – MathScholar
    Oct 26 '18 at 17:23








  • 1





    Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

    – Skillmon
    Oct 26 '18 at 17:24








  • 3





    @Skillmon samples at={0,0.05,...,1,1.5,...,10}.

    – marmot
    Oct 26 '18 at 17:53














2












2








2







Because your sample is not large enough: by default it is 25 points. With a sample of 200 points, this works.



Edit: Modification of the sample. Many thanks to Skillmon for having the idea to modify the sample and to @marmot for giving a simple and effective example.



Your foreach loops do not need to have two variables. Only one is enough, for the displayed text to be smaller, there is the key font=scriptsize.



Edit 2:
And to avoid repeating this for each node, just do it with every node/.style={font=scriptsize} to overwrite the pre-existing style or every node/append style={font=scriptsize} to simply add this style to the pre-existing style without overwriting it.



documentclass{article}
usepackage{tikz,pgfplots}
begin{document}
begin{tikzpicture}[scale=.6,cap=round,every node/.style={font=scriptsize}]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x in {1, ..., 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{ x};
foreach y in {-3,..., 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{ y};

filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{$(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{$(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->,samples at={0,0.05,...,1,1.5,...,10.5}] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}
end{document}


plot






share|improve this answer















Because your sample is not large enough: by default it is 25 points. With a sample of 200 points, this works.



Edit: Modification of the sample. Many thanks to Skillmon for having the idea to modify the sample and to @marmot for giving a simple and effective example.



Your foreach loops do not need to have two variables. Only one is enough, for the displayed text to be smaller, there is the key font=scriptsize.



Edit 2:
And to avoid repeating this for each node, just do it with every node/.style={font=scriptsize} to overwrite the pre-existing style or every node/append style={font=scriptsize} to simply add this style to the pre-existing style without overwriting it.



documentclass{article}
usepackage{tikz,pgfplots}
begin{document}
begin{tikzpicture}[scale=.6,cap=round,every node/.style={font=scriptsize}]
tikzset{axes/.style={}}
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
begin{scope}[style=axes]
draw[->] (-0.5,0) -- (10.5,0) node[right] {$x$};
draw[->] (0,-3.5) -- (0,5.5) node[above] {$y$};
foreach x in {1, ..., 10}
draw[xshift=x cm] (0pt,2.6pt) -- (0pt,-2.6pt) node[below,fill=white]
{ x};
foreach y in {-3,..., 5}
draw[yshift=y cm] (2.6pt,0pt) -- (-2.6pt,0pt) node[left,fill=white]
{ y};

filldraw[blue] (0,0) circle (3pt) node[fill=white,below right=12pt]
{$(0,0)$};
filldraw[blue] (1,1) circle (3pt) node[fill=white,above=3pt] {
$(1,1)$};
filldraw[blue] (3,1.732) circle (3pt) node[fill=white,below=3pt]
{$(3,sqrt{3})$};
filldraw[blue] (4,2) circle (3pt) node[fill=white,above=3pt] {
$(4,2)$};
filldraw[blue] (9,3) circle (3pt) node[fill=white,above=3pt] {
$(9,3)$};
draw[domain=0:10,smooth,variable=x,blue,thick,->,samples at={0,0.05,...,1,1.5,...,10.5}] plot ({x},{(x)^.5});
end{scope}
end{tikzpicture}
end{document}


plot







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 26 '18 at 19:23

























answered Oct 26 '18 at 17:05









AndréCAndréC

10.6k11548




10.6k11548








  • 1





    I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

    – Skillmon
    Oct 26 '18 at 17:13











  • @Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

    – AndréC
    Oct 26 '18 at 17:21











  • @Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

    – MathScholar
    Oct 26 '18 at 17:23








  • 1





    Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

    – Skillmon
    Oct 26 '18 at 17:24








  • 3





    @Skillmon samples at={0,0.05,...,1,1.5,...,10}.

    – marmot
    Oct 26 '18 at 17:53














  • 1





    I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

    – Skillmon
    Oct 26 '18 at 17:13











  • @Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

    – AndréC
    Oct 26 '18 at 17:21











  • @Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

    – MathScholar
    Oct 26 '18 at 17:23








  • 1





    Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

    – Skillmon
    Oct 26 '18 at 17:24








  • 3





    @Skillmon samples at={0,0.05,...,1,1.5,...,10}.

    – marmot
    Oct 26 '18 at 17:53








1




1





I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

– Skillmon
Oct 26 '18 at 17:13





I'd suggest raising the number of samples only in the interval [0,1] and not on the rest. This way one could use less samples (better performance). The gradient isn't changing much on the interval [1,10], so one doesn't need that many.

– Skillmon
Oct 26 '18 at 17:13













@Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

– AndréC
Oct 26 '18 at 17:21





@Skillmon It's a good idea, but since I'm starting with pgfplots, I don't know how to do it. Write an answer explaining how to do it!

– AndréC
Oct 26 '18 at 17:21













@Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

– MathScholar
Oct 26 '18 at 17:23







@Andre' , Thanks and In your opinion is there advantage using pgfplots instead? For some reason I want to do all my plotting as in the example above. Again Thanks!

– MathScholar
Oct 26 '18 at 17:23






1




1





Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

– Skillmon
Oct 26 '18 at 17:24







Just split the plot in two parts, like draw[domain=0:1, samples=50, smooth, variable=x] plot ({x},{(x)^.5}); draw[domain=1:10, smooth, variable=x] plot ({x},{(x)^.5});. By the way, you're not using pgfplots here, but TikZ and its plot capabilities (pgfplots is another package) :)

– Skillmon
Oct 26 '18 at 17:24






3




3





@Skillmon samples at={0,0.05,...,1,1.5,...,10}.

– marmot
Oct 26 '18 at 17:53





@Skillmon samples at={0,0.05,...,1,1.5,...,10}.

– marmot
Oct 26 '18 at 17:53


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456928%2fproblem-with-plotting-square-root-in-tikz%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

IEEEtran - How to include ORCID in TeX/PDF with PdfLatexIs there a standard way to include ORCID in TeX /...

Can't compile dgruyter and caption packagesLaTeX templates/packages for writing a patent specificationLatex...

Forked arrows with chemfig Unicorn Meta Zoo #1: Why another podcast? ...