How do I create a curve on Latex?How to create a Ricker Wavelet in TikZHow to plot a curve between two nodes?how to create scatter of points?How to draw a parametric 3D curve in tikzHow Can I Decorate a Parametric Curve?Draw curve in same curve smallPlot an elliptic curve in LatexDrawing a sideways parabolic curve in tikzLatex plots wrong curveS-curve in latexdrawing roc curve analysis

How badly should I try to prevent a user from XSSing themselves?

Is it possible to map the firing of neurons in the human brain so as to stimulate artificial memories in someone else?

Implication of namely

How to install cross-compiler on Ubuntu 18.04?

Could neural networks be considered metaheuristics?

Where would I need my direct neural interface to be implanted?

Processor speed limited at 0.4 Ghz

Blending or harmonizing

Why was Sir Cadogan fired?

Placement of More Information/Help Icon button for Radio Buttons

Calculate the Mean mean of two numbers

Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?

Is it a bad idea to plug the other end of ESD strap to wall ground?

Can a virus destroy the BIOS of a modern computer?

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

How to prevent "they're falling in love" trope

What do you call someone who asks many questions?

How can I prove that a state of equilibrium is unstable?

Can compressed videos be decoded back to their uncompresed original format?

How to travel to Japan while expressing milk?

Does Dispel Magic work on Tiny Hut?

Is there a hemisphere-neutral way of specifying a season?

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

How to remove border from elements in the last row?



How do I create a curve on Latex?


How to create a Ricker Wavelet in TikZHow to plot a curve between two nodes?how to create scatter of points?How to draw a parametric 3D curve in tikzHow Can I Decorate a Parametric Curve?Draw curve in same curve smallPlot an elliptic curve in LatexDrawing a sideways parabolic curve in tikzLatex plots wrong curveS-curve in latexdrawing roc curve analysis













1















I want to create a curve using tikz. As can be seen, the curve is made of connected lines with no rounded connection points and I would like to round off the edges. Following is my code:



documentclass[11pt, a4paper]report
usepackage[utf8]inputenc
usepackageamsmath
usepackagebm
usepackagenomencl
makenomenclature
usepackagefloat
usepackage[comma]natbib
usepackagepgfplots
usepackage[super]nth
usepackagetextcomp
usepackagemultirow
usepackage[version=3]mhchem
usepackagebooktabs
usepackagegraphicx
usepackage[margin=1in]geometry
usepackage[hidelinks]hyperref
usepackagesiunitx
usepackagetikz
renewcommandsectionautorefnameSection
renewcommandchapterautorefnameChapter
parskip=0.05in

begindocument
begintikzpicture
labelsim
beginaxis[
xlabel=Hydration time (h),
ylabel=Hydration heat evolution rate (J/gh),
xmin=0, xmax=100,
ymin=0, ymax=20,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
]

addplot[
color=blue,
]
coordinates
(0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026) (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81) (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32) (26,2.58) (27.5,2.33) (30,2.12) (40,1.12) (50,0.85) (80,0.6972) (99,0.648)
;
legendLayers 1 to 5

endaxis
endtikzpicture
enddocument


enter image description here










share|improve this question



















  • 1





    Welcome to TeX.SE. Where are into your code begindocument and enddocument?

    – Sebastiano
    Sep 5 '18 at 10:46












  • Sorry forgot to add that. I edited it now :)

    – user157109
    Sep 5 '18 at 10:49






  • 1





    @user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

    – Phelype Oleinik
    Sep 5 '18 at 11:07







  • 1





    @Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

    – daleif
    Sep 5 '18 at 11:10







  • 2





    @Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

    – Phelype Oleinik
    Sep 5 '18 at 11:11















1















I want to create a curve using tikz. As can be seen, the curve is made of connected lines with no rounded connection points and I would like to round off the edges. Following is my code:



documentclass[11pt, a4paper]report
usepackage[utf8]inputenc
usepackageamsmath
usepackagebm
usepackagenomencl
makenomenclature
usepackagefloat
usepackage[comma]natbib
usepackagepgfplots
usepackage[super]nth
usepackagetextcomp
usepackagemultirow
usepackage[version=3]mhchem
usepackagebooktabs
usepackagegraphicx
usepackage[margin=1in]geometry
usepackage[hidelinks]hyperref
usepackagesiunitx
usepackagetikz
renewcommandsectionautorefnameSection
renewcommandchapterautorefnameChapter
parskip=0.05in

begindocument
begintikzpicture
labelsim
beginaxis[
xlabel=Hydration time (h),
ylabel=Hydration heat evolution rate (J/gh),
xmin=0, xmax=100,
ymin=0, ymax=20,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
]

addplot[
color=blue,
]
coordinates
(0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026) (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81) (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32) (26,2.58) (27.5,2.33) (30,2.12) (40,1.12) (50,0.85) (80,0.6972) (99,0.648)
;
legendLayers 1 to 5

endaxis
endtikzpicture
enddocument


enter image description here










share|improve this question



















  • 1





    Welcome to TeX.SE. Where are into your code begindocument and enddocument?

    – Sebastiano
    Sep 5 '18 at 10:46












  • Sorry forgot to add that. I edited it now :)

    – user157109
    Sep 5 '18 at 10:49






  • 1





    @user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

    – Phelype Oleinik
    Sep 5 '18 at 11:07







  • 1





    @Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

    – daleif
    Sep 5 '18 at 11:10







  • 2





    @Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

    – Phelype Oleinik
    Sep 5 '18 at 11:11













1












1








1








I want to create a curve using tikz. As can be seen, the curve is made of connected lines with no rounded connection points and I would like to round off the edges. Following is my code:



documentclass[11pt, a4paper]report
usepackage[utf8]inputenc
usepackageamsmath
usepackagebm
usepackagenomencl
makenomenclature
usepackagefloat
usepackage[comma]natbib
usepackagepgfplots
usepackage[super]nth
usepackagetextcomp
usepackagemultirow
usepackage[version=3]mhchem
usepackagebooktabs
usepackagegraphicx
usepackage[margin=1in]geometry
usepackage[hidelinks]hyperref
usepackagesiunitx
usepackagetikz
renewcommandsectionautorefnameSection
renewcommandchapterautorefnameChapter
parskip=0.05in

begindocument
begintikzpicture
labelsim
beginaxis[
xlabel=Hydration time (h),
ylabel=Hydration heat evolution rate (J/gh),
xmin=0, xmax=100,
ymin=0, ymax=20,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
]

addplot[
color=blue,
]
coordinates
(0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026) (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81) (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32) (26,2.58) (27.5,2.33) (30,2.12) (40,1.12) (50,0.85) (80,0.6972) (99,0.648)
;
legendLayers 1 to 5

endaxis
endtikzpicture
enddocument


enter image description here










share|improve this question
















I want to create a curve using tikz. As can be seen, the curve is made of connected lines with no rounded connection points and I would like to round off the edges. Following is my code:



documentclass[11pt, a4paper]report
usepackage[utf8]inputenc
usepackageamsmath
usepackagebm
usepackagenomencl
makenomenclature
usepackagefloat
usepackage[comma]natbib
usepackagepgfplots
usepackage[super]nth
usepackagetextcomp
usepackagemultirow
usepackage[version=3]mhchem
usepackagebooktabs
usepackagegraphicx
usepackage[margin=1in]geometry
usepackage[hidelinks]hyperref
usepackagesiunitx
usepackagetikz
renewcommandsectionautorefnameSection
renewcommandchapterautorefnameChapter
parskip=0.05in

begindocument
begintikzpicture
labelsim
beginaxis[
xlabel=Hydration time (h),
ylabel=Hydration heat evolution rate (J/gh),
xmin=0, xmax=100,
ymin=0, ymax=20,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
]

addplot[
color=blue,
]
coordinates
(0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026) (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81) (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32) (26,2.58) (27.5,2.33) (30,2.12) (40,1.12) (50,0.85) (80,0.6972) (99,0.648)
;
legendLayers 1 to 5

endaxis
endtikzpicture
enddocument


enter image description here







tikz-pgf plot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 5 '18 at 11:14







user157109

















asked Sep 5 '18 at 10:41









user157109user157109

85




85







  • 1





    Welcome to TeX.SE. Where are into your code begindocument and enddocument?

    – Sebastiano
    Sep 5 '18 at 10:46












  • Sorry forgot to add that. I edited it now :)

    – user157109
    Sep 5 '18 at 10:49






  • 1





    @user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

    – Phelype Oleinik
    Sep 5 '18 at 11:07







  • 1





    @Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

    – daleif
    Sep 5 '18 at 11:10







  • 2





    @Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

    – Phelype Oleinik
    Sep 5 '18 at 11:11












  • 1





    Welcome to TeX.SE. Where are into your code begindocument and enddocument?

    – Sebastiano
    Sep 5 '18 at 10:46












  • Sorry forgot to add that. I edited it now :)

    – user157109
    Sep 5 '18 at 10:49






  • 1





    @user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

    – Phelype Oleinik
    Sep 5 '18 at 11:07







  • 1





    @Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

    – daleif
    Sep 5 '18 at 11:10







  • 2





    @Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

    – Phelype Oleinik
    Sep 5 '18 at 11:11







1




1





Welcome to TeX.SE. Where are into your code begindocument and enddocument?

– Sebastiano
Sep 5 '18 at 10:46






Welcome to TeX.SE. Where are into your code begindocument and enddocument?

– Sebastiano
Sep 5 '18 at 10:46














Sorry forgot to add that. I edited it now :)

– user157109
Sep 5 '18 at 10:49





Sorry forgot to add that. I edited it now :)

– user157109
Sep 5 '18 at 10:49




1




1





@user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

– Phelype Oleinik
Sep 5 '18 at 11:07






@user157109 I don't understand what you want, but I guess that the option line join = round or the option smooth do what you want. Also, there's something wrong with the data point (27,5,2.33), which is causing the error Sebastiano mentioned.

– Phelype Oleinik
Sep 5 '18 at 11:07





1




1





@Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

– daleif
Sep 5 '18 at 11:10






@Sebastiano this is a point plot, there are no samples to increase. smooth might help. But not much

– daleif
Sep 5 '18 at 11:10





2




2





@Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

– Phelype Oleinik
Sep 5 '18 at 11:11





@Sebastiano I don't know for sure, I'm not an expert here. But I think that the samples option is valid when you have an analytical function, not a discrete data set.

– Phelype Oleinik
Sep 5 '18 at 11:11










1 Answer
1






active

oldest

votes


















0














As daleif said PGFPlots can't do much about the data you give it to plot. If it was an analytical (and smooth) function you could simply increase the number of samples and the plot would look smoother. With a discrete dataset there is not much that can be done; any graphing software won't do much more than connecting the dots.



PGFPlots however offers you some work-arounds to smoothen your plot without giving it more data.



Here's your original picture (with a few spy lenses):




enter image description here




If I add the smooth option PGFPlots will, instead of a straight line, try to join your points with a smooth line. Smooth meaning that the tangent to the line is the same to the left and to the right of the point. This can make some weird output if the data points are too close and can't be drawn with a smooth line without overshooting. Your plot with smooth:




enter image description here




The peak of the plot looks OK, but the second spy lens highlights a slight overshoot. That happened because the data points are too close and the tangent of the line changes too drastically between them.



The smooth option has a default “tension” for the line, which does more or less as the name says: the tension at the data points, which will say how much of the line will be smoothed. As Mr. marmot suggested you can reduce that tension (the default is 0.5 to have a better looking curve (picture with tension=0.3):




enter image description here




Unfortunately you can't go much further without changing the underlying data.



Here's the code I used for the pictures:



documentclass[tikz]standalone
usepackagepgfplots
usetikzlibraryspy
usetikzlibrarycalc
begindocument
begintikzpicture[spy using outlines]
beginaxis[
xlabel=Hydration time (h),
ylabel=Hydration heat evolution rate (J/gh),
xmin=0, xmax=100,
ymin=0, ymax=20,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
]
addplot[
color=blue,
smooth,
tension=0.3,
]
coordinates

(0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026)
(3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81)
(11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32)
(26,2.58) (27.5,2.33) (30,2.12) (40,1.12)
(50,0.85) (80,0.6972) (99,0.648)
;
legendLayers 1 to 5
coordinate (peak) at (axis cs:3.5,18.63);
coordinate (midd) at (axis cs:15,5.04);
endaxis
spy [circle, magnification = 4, size = 1.5cm, connect spies] on (peak) in node at ($(peak)+(1.2,-1)$);
spy [circle, magnification = 4, size = 1.5cm, connect spies] on (midd) in node at ($(midd)+(1.2, 1)$);
endtikzpicture
enddocument



Where to put smooth and tension=0.3?



PGFPlots runs on TeX, and one of TeX's features is scoping. This coping applies to PGFPlots as well. There are four places where you can put these options and they will have different scopes:



  1. Somewhere in the preamble put tikzsetsmooth,tension=0.3: this will affect all tikzpictures from that point on; this has a global effect and will be used in any drawing you have (not really recommended).


  2. As an option to tikzpicture (begintikzpicture[smooth,tension=0.3]): this will limit the scope of these instructions to the current tikzpicture and will affect any drawing inside it. Once the tikzpicture ends, the effect ends as well.


  3. As an option to axis (beginaxis[smooth,tension=0.3]): same as above, but the effect will be limited to that axis.


  4. As an option to addplot (addplot[smooth,tension=0.3]): the scope of the options will be limited to that plot only. Any other plot, even in the same axis, will have the default options. Since you want to smoothen this specific curve, this is the way to go, as the scope is exactly the one you want.





share























    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%2f449424%2fhow-do-i-create-a-curve-on-latex%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









    0














    As daleif said PGFPlots can't do much about the data you give it to plot. If it was an analytical (and smooth) function you could simply increase the number of samples and the plot would look smoother. With a discrete dataset there is not much that can be done; any graphing software won't do much more than connecting the dots.



    PGFPlots however offers you some work-arounds to smoothen your plot without giving it more data.



    Here's your original picture (with a few spy lenses):




    enter image description here




    If I add the smooth option PGFPlots will, instead of a straight line, try to join your points with a smooth line. Smooth meaning that the tangent to the line is the same to the left and to the right of the point. This can make some weird output if the data points are too close and can't be drawn with a smooth line without overshooting. Your plot with smooth:




    enter image description here




    The peak of the plot looks OK, but the second spy lens highlights a slight overshoot. That happened because the data points are too close and the tangent of the line changes too drastically between them.



    The smooth option has a default “tension” for the line, which does more or less as the name says: the tension at the data points, which will say how much of the line will be smoothed. As Mr. marmot suggested you can reduce that tension (the default is 0.5 to have a better looking curve (picture with tension=0.3):




    enter image description here




    Unfortunately you can't go much further without changing the underlying data.



    Here's the code I used for the pictures:



    documentclass[tikz]standalone
    usepackagepgfplots
    usetikzlibraryspy
    usetikzlibrarycalc
    begindocument
    begintikzpicture[spy using outlines]
    beginaxis[
    xlabel=Hydration time (h),
    ylabel=Hydration heat evolution rate (J/gh),
    xmin=0, xmax=100,
    ymin=0, ymax=20,
    legend pos=north east,
    ymajorgrids=true,
    grid style=dashed,
    ]
    addplot[
    color=blue,
    smooth,
    tension=0.3,
    ]
    coordinates

    (0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026)
    (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81)
    (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32)
    (26,2.58) (27.5,2.33) (30,2.12) (40,1.12)
    (50,0.85) (80,0.6972) (99,0.648)
    ;
    legendLayers 1 to 5
    coordinate (peak) at (axis cs:3.5,18.63);
    coordinate (midd) at (axis cs:15,5.04);
    endaxis
    spy [circle, magnification = 4, size = 1.5cm, connect spies] on (peak) in node at ($(peak)+(1.2,-1)$);
    spy [circle, magnification = 4, size = 1.5cm, connect spies] on (midd) in node at ($(midd)+(1.2, 1)$);
    endtikzpicture
    enddocument



    Where to put smooth and tension=0.3?



    PGFPlots runs on TeX, and one of TeX's features is scoping. This coping applies to PGFPlots as well. There are four places where you can put these options and they will have different scopes:



    1. Somewhere in the preamble put tikzsetsmooth,tension=0.3: this will affect all tikzpictures from that point on; this has a global effect and will be used in any drawing you have (not really recommended).


    2. As an option to tikzpicture (begintikzpicture[smooth,tension=0.3]): this will limit the scope of these instructions to the current tikzpicture and will affect any drawing inside it. Once the tikzpicture ends, the effect ends as well.


    3. As an option to axis (beginaxis[smooth,tension=0.3]): same as above, but the effect will be limited to that axis.


    4. As an option to addplot (addplot[smooth,tension=0.3]): the scope of the options will be limited to that plot only. Any other plot, even in the same axis, will have the default options. Since you want to smoothen this specific curve, this is the way to go, as the scope is exactly the one you want.





    share



























      0














      As daleif said PGFPlots can't do much about the data you give it to plot. If it was an analytical (and smooth) function you could simply increase the number of samples and the plot would look smoother. With a discrete dataset there is not much that can be done; any graphing software won't do much more than connecting the dots.



      PGFPlots however offers you some work-arounds to smoothen your plot without giving it more data.



      Here's your original picture (with a few spy lenses):




      enter image description here




      If I add the smooth option PGFPlots will, instead of a straight line, try to join your points with a smooth line. Smooth meaning that the tangent to the line is the same to the left and to the right of the point. This can make some weird output if the data points are too close and can't be drawn with a smooth line without overshooting. Your plot with smooth:




      enter image description here




      The peak of the plot looks OK, but the second spy lens highlights a slight overshoot. That happened because the data points are too close and the tangent of the line changes too drastically between them.



      The smooth option has a default “tension” for the line, which does more or less as the name says: the tension at the data points, which will say how much of the line will be smoothed. As Mr. marmot suggested you can reduce that tension (the default is 0.5 to have a better looking curve (picture with tension=0.3):




      enter image description here




      Unfortunately you can't go much further without changing the underlying data.



      Here's the code I used for the pictures:



      documentclass[tikz]standalone
      usepackagepgfplots
      usetikzlibraryspy
      usetikzlibrarycalc
      begindocument
      begintikzpicture[spy using outlines]
      beginaxis[
      xlabel=Hydration time (h),
      ylabel=Hydration heat evolution rate (J/gh),
      xmin=0, xmax=100,
      ymin=0, ymax=20,
      legend pos=north east,
      ymajorgrids=true,
      grid style=dashed,
      ]
      addplot[
      color=blue,
      smooth,
      tension=0.3,
      ]
      coordinates

      (0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026)
      (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81)
      (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32)
      (26,2.58) (27.5,2.33) (30,2.12) (40,1.12)
      (50,0.85) (80,0.6972) (99,0.648)
      ;
      legendLayers 1 to 5
      coordinate (peak) at (axis cs:3.5,18.63);
      coordinate (midd) at (axis cs:15,5.04);
      endaxis
      spy [circle, magnification = 4, size = 1.5cm, connect spies] on (peak) in node at ($(peak)+(1.2,-1)$);
      spy [circle, magnification = 4, size = 1.5cm, connect spies] on (midd) in node at ($(midd)+(1.2, 1)$);
      endtikzpicture
      enddocument



      Where to put smooth and tension=0.3?



      PGFPlots runs on TeX, and one of TeX's features is scoping. This coping applies to PGFPlots as well. There are four places where you can put these options and they will have different scopes:



      1. Somewhere in the preamble put tikzsetsmooth,tension=0.3: this will affect all tikzpictures from that point on; this has a global effect and will be used in any drawing you have (not really recommended).


      2. As an option to tikzpicture (begintikzpicture[smooth,tension=0.3]): this will limit the scope of these instructions to the current tikzpicture and will affect any drawing inside it. Once the tikzpicture ends, the effect ends as well.


      3. As an option to axis (beginaxis[smooth,tension=0.3]): same as above, but the effect will be limited to that axis.


      4. As an option to addplot (addplot[smooth,tension=0.3]): the scope of the options will be limited to that plot only. Any other plot, even in the same axis, will have the default options. Since you want to smoothen this specific curve, this is the way to go, as the scope is exactly the one you want.





      share

























        0












        0








        0







        As daleif said PGFPlots can't do much about the data you give it to plot. If it was an analytical (and smooth) function you could simply increase the number of samples and the plot would look smoother. With a discrete dataset there is not much that can be done; any graphing software won't do much more than connecting the dots.



        PGFPlots however offers you some work-arounds to smoothen your plot without giving it more data.



        Here's your original picture (with a few spy lenses):




        enter image description here




        If I add the smooth option PGFPlots will, instead of a straight line, try to join your points with a smooth line. Smooth meaning that the tangent to the line is the same to the left and to the right of the point. This can make some weird output if the data points are too close and can't be drawn with a smooth line without overshooting. Your plot with smooth:




        enter image description here




        The peak of the plot looks OK, but the second spy lens highlights a slight overshoot. That happened because the data points are too close and the tangent of the line changes too drastically between them.



        The smooth option has a default “tension” for the line, which does more or less as the name says: the tension at the data points, which will say how much of the line will be smoothed. As Mr. marmot suggested you can reduce that tension (the default is 0.5 to have a better looking curve (picture with tension=0.3):




        enter image description here




        Unfortunately you can't go much further without changing the underlying data.



        Here's the code I used for the pictures:



        documentclass[tikz]standalone
        usepackagepgfplots
        usetikzlibraryspy
        usetikzlibrarycalc
        begindocument
        begintikzpicture[spy using outlines]
        beginaxis[
        xlabel=Hydration time (h),
        ylabel=Hydration heat evolution rate (J/gh),
        xmin=0, xmax=100,
        ymin=0, ymax=20,
        legend pos=north east,
        ymajorgrids=true,
        grid style=dashed,
        ]
        addplot[
        color=blue,
        smooth,
        tension=0.3,
        ]
        coordinates

        (0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026)
        (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81)
        (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32)
        (26,2.58) (27.5,2.33) (30,2.12) (40,1.12)
        (50,0.85) (80,0.6972) (99,0.648)
        ;
        legendLayers 1 to 5
        coordinate (peak) at (axis cs:3.5,18.63);
        coordinate (midd) at (axis cs:15,5.04);
        endaxis
        spy [circle, magnification = 4, size = 1.5cm, connect spies] on (peak) in node at ($(peak)+(1.2,-1)$);
        spy [circle, magnification = 4, size = 1.5cm, connect spies] on (midd) in node at ($(midd)+(1.2, 1)$);
        endtikzpicture
        enddocument



        Where to put smooth and tension=0.3?



        PGFPlots runs on TeX, and one of TeX's features is scoping. This coping applies to PGFPlots as well. There are four places where you can put these options and they will have different scopes:



        1. Somewhere in the preamble put tikzsetsmooth,tension=0.3: this will affect all tikzpictures from that point on; this has a global effect and will be used in any drawing you have (not really recommended).


        2. As an option to tikzpicture (begintikzpicture[smooth,tension=0.3]): this will limit the scope of these instructions to the current tikzpicture and will affect any drawing inside it. Once the tikzpicture ends, the effect ends as well.


        3. As an option to axis (beginaxis[smooth,tension=0.3]): same as above, but the effect will be limited to that axis.


        4. As an option to addplot (addplot[smooth,tension=0.3]): the scope of the options will be limited to that plot only. Any other plot, even in the same axis, will have the default options. Since you want to smoothen this specific curve, this is the way to go, as the scope is exactly the one you want.





        share













        As daleif said PGFPlots can't do much about the data you give it to plot. If it was an analytical (and smooth) function you could simply increase the number of samples and the plot would look smoother. With a discrete dataset there is not much that can be done; any graphing software won't do much more than connecting the dots.



        PGFPlots however offers you some work-arounds to smoothen your plot without giving it more data.



        Here's your original picture (with a few spy lenses):




        enter image description here




        If I add the smooth option PGFPlots will, instead of a straight line, try to join your points with a smooth line. Smooth meaning that the tangent to the line is the same to the left and to the right of the point. This can make some weird output if the data points are too close and can't be drawn with a smooth line without overshooting. Your plot with smooth:




        enter image description here




        The peak of the plot looks OK, but the second spy lens highlights a slight overshoot. That happened because the data points are too close and the tangent of the line changes too drastically between them.



        The smooth option has a default “tension” for the line, which does more or less as the name says: the tension at the data points, which will say how much of the line will be smoothed. As Mr. marmot suggested you can reduce that tension (the default is 0.5 to have a better looking curve (picture with tension=0.3):




        enter image description here




        Unfortunately you can't go much further without changing the underlying data.



        Here's the code I used for the pictures:



        documentclass[tikz]standalone
        usepackagepgfplots
        usetikzlibraryspy
        usetikzlibrarycalc
        begindocument
        begintikzpicture[spy using outlines]
        beginaxis[
        xlabel=Hydration time (h),
        ylabel=Hydration heat evolution rate (J/gh),
        xmin=0, xmax=100,
        ymin=0, ymax=20,
        legend pos=north east,
        ymajorgrids=true,
        grid style=dashed,
        ]
        addplot[
        color=blue,
        smooth,
        tension=0.3,
        ]
        coordinates

        (0,0) (0.5,3.59) (1.5,8.65) (2.5,15.026)
        (3.5,18.63) (4,18.07) (4.5,15.91) (6.5,9.81)
        (11.5,6.06) (15,5.04) (15.5,4.788) (20.5,3.32)
        (26,2.58) (27.5,2.33) (30,2.12) (40,1.12)
        (50,0.85) (80,0.6972) (99,0.648)
        ;
        legendLayers 1 to 5
        coordinate (peak) at (axis cs:3.5,18.63);
        coordinate (midd) at (axis cs:15,5.04);
        endaxis
        spy [circle, magnification = 4, size = 1.5cm, connect spies] on (peak) in node at ($(peak)+(1.2,-1)$);
        spy [circle, magnification = 4, size = 1.5cm, connect spies] on (midd) in node at ($(midd)+(1.2, 1)$);
        endtikzpicture
        enddocument



        Where to put smooth and tension=0.3?



        PGFPlots runs on TeX, and one of TeX's features is scoping. This coping applies to PGFPlots as well. There are four places where you can put these options and they will have different scopes:



        1. Somewhere in the preamble put tikzsetsmooth,tension=0.3: this will affect all tikzpictures from that point on; this has a global effect and will be used in any drawing you have (not really recommended).


        2. As an option to tikzpicture (begintikzpicture[smooth,tension=0.3]): this will limit the scope of these instructions to the current tikzpicture and will affect any drawing inside it. Once the tikzpicture ends, the effect ends as well.


        3. As an option to axis (beginaxis[smooth,tension=0.3]): same as above, but the effect will be limited to that axis.


        4. As an option to addplot (addplot[smooth,tension=0.3]): the scope of the options will be limited to that plot only. Any other plot, even in the same axis, will have the default options. Since you want to smoothen this specific curve, this is the way to go, as the scope is exactly the one you want.






        share











        share


        share










        answered 5 mins ago









        Phelype OleinikPhelype Oleinik

        24.7k54688




        24.7k54688



























            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%2f449424%2fhow-do-i-create-a-curve-on-latex%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

            How should I use the fbox command correctly to avoid producing a Bad Box message?How to put a long piece of text in a box?How to specify height and width of fboxIs there an arrayrulecolor-like command to change the rule color of fbox?What is the command to highlight bad boxes in pdf?Why does fbox sometimes place the box *over* the graphic image?how to put the text in the boxHow to create command for a box where text inside the box can automatically adjust?how can I make an fbox like command with certain color, shape and width of border?how to use fbox in align modeFbox increase the spacing between the box and it content (inner margin)how to change the box height of an equationWhat is the use of the hbox in a newcommand command?

            Doxepinum Nexus interni Notae | Tabula navigationis3158DB01142WHOa682390"Structural Analysis of the Histamine H1 Receptor""Transdermal and Topical Drug Administration in the Treatment of Pain""Antidepressants as antipruritic agents: A review"

            Haugesund Nexus externi | Tabula navigationisHaugesund pagina interretialisAmplifica