PGFPlots with TikZ produces unstable plots












2















I'm currently trying to get some of my Octave plots to work natively in a LaTeX document. My method of choice is to use the plot parameters of my Octave scripts in a standalone TikZ document that uses PGFPlots and is imported to a larger LaTeX document with some discussion on the results. Unfortunately, there have been some setbacks in my first foray to PGFPlots.



It seems that the plot bears little resemblance to the plot in the Octave script and that the plot is unstable in the sense that its axis offset and its slope change when I adjust the seemingly unrelated axis properties.



Here is the code:



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
compat=newest
]
addplot {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


The plot passes through the origin even if the formula defines offset. Furthermore, adjustment to the x-domain restrictions change the slope of the plot. I worry that there is a feature of PGFPlots that I'm not yet familiar with and which is distorting my plots.



A plot without offset



To compare, the following Octave plot has a clear offset from the origin for the corresponding red line.Octave plot with an offset










share|improve this question




















  • 1





    Could you add your octave plot for reference, so that we can also try to see the problem?

    – Raaja
    Nov 22 '18 at 12:33













  • I'm adding the reference. The red line corresponds to the blue line above.

    – Tommi Rimpiläinen
    Nov 22 '18 at 12:50






  • 3





    You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

    – marmot
    Nov 22 '18 at 12:54


















2















I'm currently trying to get some of my Octave plots to work natively in a LaTeX document. My method of choice is to use the plot parameters of my Octave scripts in a standalone TikZ document that uses PGFPlots and is imported to a larger LaTeX document with some discussion on the results. Unfortunately, there have been some setbacks in my first foray to PGFPlots.



It seems that the plot bears little resemblance to the plot in the Octave script and that the plot is unstable in the sense that its axis offset and its slope change when I adjust the seemingly unrelated axis properties.



Here is the code:



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
compat=newest
]
addplot {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


The plot passes through the origin even if the formula defines offset. Furthermore, adjustment to the x-domain restrictions change the slope of the plot. I worry that there is a feature of PGFPlots that I'm not yet familiar with and which is distorting my plots.



A plot without offset



To compare, the following Octave plot has a clear offset from the origin for the corresponding red line.Octave plot with an offset










share|improve this question




















  • 1





    Could you add your octave plot for reference, so that we can also try to see the problem?

    – Raaja
    Nov 22 '18 at 12:33













  • I'm adding the reference. The red line corresponds to the blue line above.

    – Tommi Rimpiläinen
    Nov 22 '18 at 12:50






  • 3





    You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

    – marmot
    Nov 22 '18 at 12:54
















2












2








2


1






I'm currently trying to get some of my Octave plots to work natively in a LaTeX document. My method of choice is to use the plot parameters of my Octave scripts in a standalone TikZ document that uses PGFPlots and is imported to a larger LaTeX document with some discussion on the results. Unfortunately, there have been some setbacks in my first foray to PGFPlots.



It seems that the plot bears little resemblance to the plot in the Octave script and that the plot is unstable in the sense that its axis offset and its slope change when I adjust the seemingly unrelated axis properties.



Here is the code:



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
compat=newest
]
addplot {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


The plot passes through the origin even if the formula defines offset. Furthermore, adjustment to the x-domain restrictions change the slope of the plot. I worry that there is a feature of PGFPlots that I'm not yet familiar with and which is distorting my plots.



A plot without offset



To compare, the following Octave plot has a clear offset from the origin for the corresponding red line.Octave plot with an offset










share|improve this question
















I'm currently trying to get some of my Octave plots to work natively in a LaTeX document. My method of choice is to use the plot parameters of my Octave scripts in a standalone TikZ document that uses PGFPlots and is imported to a larger LaTeX document with some discussion on the results. Unfortunately, there have been some setbacks in my first foray to PGFPlots.



It seems that the plot bears little resemblance to the plot in the Octave script and that the plot is unstable in the sense that its axis offset and its slope change when I adjust the seemingly unrelated axis properties.



Here is the code:



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
compat=newest
]
addplot {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


The plot passes through the origin even if the formula defines offset. Furthermore, adjustment to the x-domain restrictions change the slope of the plot. I worry that there is a feature of PGFPlots that I'm not yet familiar with and which is distorting my plots.



A plot without offset



To compare, the following Octave plot has a clear offset from the origin for the corresponding red line.Octave plot with an offset







tikz-pgf pgfplots






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 12:49







Tommi Rimpiläinen

















asked Nov 22 '18 at 12:25









Tommi RimpiläinenTommi Rimpiläinen

134




134








  • 1





    Could you add your octave plot for reference, so that we can also try to see the problem?

    – Raaja
    Nov 22 '18 at 12:33













  • I'm adding the reference. The red line corresponds to the blue line above.

    – Tommi Rimpiläinen
    Nov 22 '18 at 12:50






  • 3





    You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

    – marmot
    Nov 22 '18 at 12:54
















  • 1





    Could you add your octave plot for reference, so that we can also try to see the problem?

    – Raaja
    Nov 22 '18 at 12:33













  • I'm adding the reference. The red line corresponds to the blue line above.

    – Tommi Rimpiläinen
    Nov 22 '18 at 12:50






  • 3





    You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

    – marmot
    Nov 22 '18 at 12:54










1




1





Could you add your octave plot for reference, so that we can also try to see the problem?

– Raaja
Nov 22 '18 at 12:33







Could you add your octave plot for reference, so that we can also try to see the problem?

– Raaja
Nov 22 '18 at 12:33















I'm adding the reference. The red line corresponds to the blue line above.

– Tommi Rimpiläinen
Nov 22 '18 at 12:50





I'm adding the reference. The red line corresponds to the blue line above.

– Tommi Rimpiläinen
Nov 22 '18 at 12:50




3




3





You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

– marmot
Nov 22 '18 at 12:54







You add all the restrictions plot in a huge domain. Try addplot[domain=-0.05:0.05] {0.000018165+0.0014500*x}; restrict x to domain*=-0.15:0.15, does not set the domain of the plot, as can be seen clearly from the fact that it runs from -4.5 to 4.5.

– marmot
Nov 22 '18 at 12:54












1 Answer
1






active

oldest

votes


















5














You are using restrict x to domain*=-0.15:0.15,restrict y to domain*=-0.0004:0.0004,, about which the manual says



enter image description here



However, you do not set an appropriate domain. If you do that,



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
domain=-0.05:0.05
]
addplot[no marks] {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


you'll get



enter image description here



which has a clearly visible offset.






share|improve this answer
























  • Adding the domain really was the key.

    – Tommi Rimpiläinen
    Nov 22 '18 at 14:09












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%2f461266%2fpgfplots-with-tikz-produces-unstable-plots%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









5














You are using restrict x to domain*=-0.15:0.15,restrict y to domain*=-0.0004:0.0004,, about which the manual says



enter image description here



However, you do not set an appropriate domain. If you do that,



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
domain=-0.05:0.05
]
addplot[no marks] {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


you'll get



enter image description here



which has a clearly visible offset.






share|improve this answer
























  • Adding the domain really was the key.

    – Tommi Rimpiläinen
    Nov 22 '18 at 14:09
















5














You are using restrict x to domain*=-0.15:0.15,restrict y to domain*=-0.0004:0.0004,, about which the manual says



enter image description here



However, you do not set an appropriate domain. If you do that,



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
domain=-0.05:0.05
]
addplot[no marks] {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


you'll get



enter image description here



which has a clearly visible offset.






share|improve this answer
























  • Adding the domain really was the key.

    – Tommi Rimpiläinen
    Nov 22 '18 at 14:09














5












5








5







You are using restrict x to domain*=-0.15:0.15,restrict y to domain*=-0.0004:0.0004,, about which the manual says



enter image description here



However, you do not set an appropriate domain. If you do that,



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
domain=-0.05:0.05
]
addplot[no marks] {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


you'll get



enter image description here



which has a clearly visible offset.






share|improve this answer













You are using restrict x to domain*=-0.15:0.15,restrict y to domain*=-0.0004:0.0004,, about which the manual says



enter image description here



However, you do not set an appropriate domain. If you do that,



documentclass[crop,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[
width=8cm,
height=6cm,
samples=6,
restrict x to domain*=-0.15:0.15,
restrict y to domain*=-0.0004:0.0004,
xmin=-0.05, xmax=0.05,
ymin=-0.0002, ymax=0.0002,
axis lines=left,
grid=both,
domain=-0.05:0.05
]
addplot[no marks] {0.000018165+0.0014500*x};
end{axis}
end{tikzpicture}
end{document}


you'll get



enter image description here



which has a clearly visible offset.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 13:02









marmotmarmot

120k6157293




120k6157293













  • Adding the domain really was the key.

    – Tommi Rimpiläinen
    Nov 22 '18 at 14:09



















  • Adding the domain really was the key.

    – Tommi Rimpiläinen
    Nov 22 '18 at 14:09

















Adding the domain really was the key.

– Tommi Rimpiläinen
Nov 22 '18 at 14:09





Adding the domain really was the key.

– Tommi Rimpiläinen
Nov 22 '18 at 14:09


















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%2f461266%2fpgfplots-with-tikz-produces-unstable-plots%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

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?