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

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

Can gravitational waves pass through a black hole?

How do I say "this must not happen"?

Do regular languages belong to Space(1)?

My mentor says to set image to Fine instead of RAW — how is this different from JPG?

Compassion's Unity

Dinosaur Word Search, Letter Solve, and Unscramble

Proving that any solution to the differential equation of an oscillator can be written as a sum of sinusoids.

malloc in main() or malloc in another function: allocating memory for a struct and its members

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

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

How does Billy Russo acquire his 'Jigsaw' mask?

How to achieve cat-like agility?

What helicopter has the most rotor blades?

Is there night in Alpha Complex?

Maximum rotation made by a symmetric positive definite matrix?

New Order #6: Easter Egg

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

Improvising over quartal voicings

Reflections in a Square

How to make an animal which can only breed for a certain number of generations?

JImage - Set generated image quality

The Nth Gryphon Number



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










1















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.



documentclassarticle
usepackagetikz

begindocument
begintikzpicture[scale=.6,cap=round]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture


enddocument


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















1















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.



documentclassarticle
usepackagetikz

begindocument
begintikzpicture[scale=.6,cap=round]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture


enddocument


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













1












1








1








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.



documentclassarticle
usepackagetikz

begindocument
begintikzpicture[scale=.6,cap=round]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture


enddocument


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.



documentclassarticle
usepackagetikz

begindocument
begintikzpicture[scale=.6,cap=round]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture


enddocument


enter image description here







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 mins ago









JouleV

14.9k22666




14.9k22666










asked Oct 26 '18 at 16:44









MathScholarMathScholar

1,10029




1,10029












  • 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.



documentclassarticle
usepackagetikz,pgfplots
begindocument
begintikzpicture[scale=.6,cap=round,every node/.style=font=scriptsize]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture
enddocument


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.



documentclassarticle
usepackagetikz,pgfplots
begindocument
begintikzpicture[scale=.6,cap=round,every node/.style=font=scriptsize]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture
enddocument


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.



documentclassarticle
usepackagetikz,pgfplots
begindocument
begintikzpicture[scale=.6,cap=round,every node/.style=font=scriptsize]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture
enddocument


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.



documentclassarticle
usepackagetikz,pgfplots
begindocument
begintikzpicture[scale=.6,cap=round,every node/.style=font=scriptsize]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture
enddocument


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.



documentclassarticle
usepackagetikz,pgfplots
begindocument
begintikzpicture[scale=.6,cap=round,every node/.style=font=scriptsize]
tikzsetaxes/.style=
% The graphic
draw[style=help lines,step=1cm, dotted] (-.5,-3.5) grid (10.5,5.5);
beginscope[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,sqrt3)$;
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);
endscope
endtikzpicture
enddocument


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

Lioubotyn Sommaire Géographie | Histoire | Population | Notes et références | Liens externes | Menu de navigationlubotin.kharkov.uamodifier« Recensements et estimations de la population depuis 1897 »« Office des statistiques d'Ukraine : population au 1er janvier 2010, 2011 et 2012 »« Office des statistiques d'Ukraine : population au 1er janvier 2011, 2012 et 2013 »Informations officiellesCartes topographiquesCarte routièrem

Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

Mpande kaSenzangakhona Biographie | Références | Menu de navigationmodifierMpande kaSenzangakhonavoir la liste des auteursm