ylim with negative floating point number

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite












Could someone explain me why the following code compile perfectly :



documentclassarticle
usepackagepgfplots
pgfplotssetcompat=1.14
pgfplotsset/pgf/number format/.cd, 1000 sep=, assume math mode=true

begindocument

begintikzpicture

beginaxis[%
width=4cm,
height=4cm,
ymin=-0.5,
ymax=0,
]
addplot [forget plot]
table[row sep=crcr]%
5 -0.000535\
;
endaxis
endtikzpicture
enddocument


while if I want



ymin=-0.1,


it does not compile anymore. Error message :



Missing $ inserted.


Clues for a possible answer :



  • if the math mode is removed, the compilation is possible in both cases. But I dont want to remove it.


  • if I have ymin=-0.1 and ymax=0.5, it compiles too ...


Well ... I dont understand.







share|improve this question


















  • 1




    Why do you need assume math mode ?
    – BambOo
    Aug 8 at 10:04










  • im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
    – Viv
    Aug 8 at 10:27










  • See my answer below
    – BambOo
    Aug 8 at 10:32






  • 1




    Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
    – BambOo
    Aug 8 at 11:17














up vote
7
down vote

favorite












Could someone explain me why the following code compile perfectly :



documentclassarticle
usepackagepgfplots
pgfplotssetcompat=1.14
pgfplotsset/pgf/number format/.cd, 1000 sep=, assume math mode=true

begindocument

begintikzpicture

beginaxis[%
width=4cm,
height=4cm,
ymin=-0.5,
ymax=0,
]
addplot [forget plot]
table[row sep=crcr]%
5 -0.000535\
;
endaxis
endtikzpicture
enddocument


while if I want



ymin=-0.1,


it does not compile anymore. Error message :



Missing $ inserted.


Clues for a possible answer :



  • if the math mode is removed, the compilation is possible in both cases. But I dont want to remove it.


  • if I have ymin=-0.1 and ymax=0.5, it compiles too ...


Well ... I dont understand.







share|improve this question


















  • 1




    Why do you need assume math mode ?
    – BambOo
    Aug 8 at 10:04










  • im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
    – Viv
    Aug 8 at 10:27










  • See my answer below
    – BambOo
    Aug 8 at 10:32






  • 1




    Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
    – BambOo
    Aug 8 at 11:17












up vote
7
down vote

favorite









up vote
7
down vote

favorite











Could someone explain me why the following code compile perfectly :



documentclassarticle
usepackagepgfplots
pgfplotssetcompat=1.14
pgfplotsset/pgf/number format/.cd, 1000 sep=, assume math mode=true

begindocument

begintikzpicture

beginaxis[%
width=4cm,
height=4cm,
ymin=-0.5,
ymax=0,
]
addplot [forget plot]
table[row sep=crcr]%
5 -0.000535\
;
endaxis
endtikzpicture
enddocument


while if I want



ymin=-0.1,


it does not compile anymore. Error message :



Missing $ inserted.


Clues for a possible answer :



  • if the math mode is removed, the compilation is possible in both cases. But I dont want to remove it.


  • if I have ymin=-0.1 and ymax=0.5, it compiles too ...


Well ... I dont understand.







share|improve this question














Could someone explain me why the following code compile perfectly :



documentclassarticle
usepackagepgfplots
pgfplotssetcompat=1.14
pgfplotsset/pgf/number format/.cd, 1000 sep=, assume math mode=true

begindocument

begintikzpicture

beginaxis[%
width=4cm,
height=4cm,
ymin=-0.5,
ymax=0,
]
addplot [forget plot]
table[row sep=crcr]%
5 -0.000535\
;
endaxis
endtikzpicture
enddocument


while if I want



ymin=-0.1,


it does not compile anymore. Error message :



Missing $ inserted.


Clues for a possible answer :



  • if the math mode is removed, the compilation is possible in both cases. But I dont want to remove it.


  • if I have ymin=-0.1 and ymax=0.5, it compiles too ...


Well ... I dont understand.









share|improve this question













share|improve this question




share|improve this question








edited Aug 8 at 9:58









Raaja

1,4571522




1,4571522










asked Aug 8 at 9:54









Viv

386




386







  • 1




    Why do you need assume math mode ?
    – BambOo
    Aug 8 at 10:04










  • im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
    – Viv
    Aug 8 at 10:27










  • See my answer below
    – BambOo
    Aug 8 at 10:32






  • 1




    Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
    – BambOo
    Aug 8 at 11:17












  • 1




    Why do you need assume math mode ?
    – BambOo
    Aug 8 at 10:04










  • im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
    – Viv
    Aug 8 at 10:27










  • See my answer below
    – BambOo
    Aug 8 at 10:32






  • 1




    Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
    – BambOo
    Aug 8 at 11:17







1




1




Why do you need assume math mode ?
– BambOo
Aug 8 at 10:04




Why do you need assume math mode ?
– BambOo
Aug 8 at 10:04












im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
– Viv
Aug 8 at 10:27




im using it elsewhere on my document ;-) maybe i can remove it and adapt the document, but this is not the point here :-(
– Viv
Aug 8 at 10:27












See my answer below
– BambOo
Aug 8 at 10:32




See my answer below
– BambOo
Aug 8 at 10:32




1




1




Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
– BambOo
Aug 8 at 11:17




Adding yticklabels= to the axis options seems to remove the error. This seems related to the automatic computation of ticks or ticklabels in this situation.
– BambOo
Aug 8 at 11:17










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










Your attempt fails, because PGFPlots changes the way the yticks/yticklabels are drawn when you change ymin to -0.1 (see left plot). And this of course cannot be drawn in text mode, because in text mode neither cdot nor ^ are known/can be interpreted.



To circumvent this problem you can change the number format of the yticklabels "back" to fixed (see right plot). (Optionally you can move the yticklabel style part to the preamble as well.)



% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
pgfplotsset
/pgf/number format/.cd,
1000 sep=,
assume math mode=true,

begindocument
% dummy plot to show where the problem is coming from
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% don't assume math mode
/pgf/number format/assume math mode=false,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
% plot showing how to circumvent the problem
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% change number format to `fixed'
yticklabel style=
/pgf/number format/fixed,
% % (optionally change the `precision' to your needs)
% /pgf/number format/precision=2,
,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
enddocument


image showing the result of above code






share|improve this answer






















  • Exactly what i was waiting for as explanation ! Thank you very much
    – Viv
    Aug 14 at 8:24

















up vote
2
down vote













If you do not need assume math mode=true for this specific tikzpicture, you can pass /pgf/number format/assume math mode=false to the axis environment options or to the tikzpicture environment options to avoid the error.






share|improve this answer




















  • another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
    – Viv
    Aug 8 at 10:35










  • Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
    – BambOo
    Aug 8 at 10:39










  • I dont think this is the reason because the problem appeared with a huge figure ;-)
    – Viv
    Aug 8 at 11:05










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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
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%2f445118%2fylim-with-negative-floating-point-number%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










Your attempt fails, because PGFPlots changes the way the yticks/yticklabels are drawn when you change ymin to -0.1 (see left plot). And this of course cannot be drawn in text mode, because in text mode neither cdot nor ^ are known/can be interpreted.



To circumvent this problem you can change the number format of the yticklabels "back" to fixed (see right plot). (Optionally you can move the yticklabel style part to the preamble as well.)



% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
pgfplotsset
/pgf/number format/.cd,
1000 sep=,
assume math mode=true,

begindocument
% dummy plot to show where the problem is coming from
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% don't assume math mode
/pgf/number format/assume math mode=false,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
% plot showing how to circumvent the problem
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% change number format to `fixed'
yticklabel style=
/pgf/number format/fixed,
% % (optionally change the `precision' to your needs)
% /pgf/number format/precision=2,
,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
enddocument


image showing the result of above code






share|improve this answer






















  • Exactly what i was waiting for as explanation ! Thank you very much
    – Viv
    Aug 14 at 8:24














up vote
3
down vote



accepted










Your attempt fails, because PGFPlots changes the way the yticks/yticklabels are drawn when you change ymin to -0.1 (see left plot). And this of course cannot be drawn in text mode, because in text mode neither cdot nor ^ are known/can be interpreted.



To circumvent this problem you can change the number format of the yticklabels "back" to fixed (see right plot). (Optionally you can move the yticklabel style part to the preamble as well.)



% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
pgfplotsset
/pgf/number format/.cd,
1000 sep=,
assume math mode=true,

begindocument
% dummy plot to show where the problem is coming from
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% don't assume math mode
/pgf/number format/assume math mode=false,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
% plot showing how to circumvent the problem
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% change number format to `fixed'
yticklabel style=
/pgf/number format/fixed,
% % (optionally change the `precision' to your needs)
% /pgf/number format/precision=2,
,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
enddocument


image showing the result of above code






share|improve this answer






















  • Exactly what i was waiting for as explanation ! Thank you very much
    – Viv
    Aug 14 at 8:24












up vote
3
down vote



accepted







up vote
3
down vote



accepted






Your attempt fails, because PGFPlots changes the way the yticks/yticklabels are drawn when you change ymin to -0.1 (see left plot). And this of course cannot be drawn in text mode, because in text mode neither cdot nor ^ are known/can be interpreted.



To circumvent this problem you can change the number format of the yticklabels "back" to fixed (see right plot). (Optionally you can move the yticklabel style part to the preamble as well.)



% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
pgfplotsset
/pgf/number format/.cd,
1000 sep=,
assume math mode=true,

begindocument
% dummy plot to show where the problem is coming from
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% don't assume math mode
/pgf/number format/assume math mode=false,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
% plot showing how to circumvent the problem
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% change number format to `fixed'
yticklabel style=
/pgf/number format/fixed,
% % (optionally change the `precision' to your needs)
% /pgf/number format/precision=2,
,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
enddocument


image showing the result of above code






share|improve this answer














Your attempt fails, because PGFPlots changes the way the yticks/yticklabels are drawn when you change ymin to -0.1 (see left plot). And this of course cannot be drawn in text mode, because in text mode neither cdot nor ^ are known/can be interpreted.



To circumvent this problem you can change the number format of the yticklabels "back" to fixed (see right plot). (Optionally you can move the yticklabel style part to the preamble as well.)



% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
pgfplotsset
/pgf/number format/.cd,
1000 sep=,
assume math mode=true,

begindocument
% dummy plot to show where the problem is coming from
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% don't assume math mode
/pgf/number format/assume math mode=false,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
% plot showing how to circumvent the problem
begintikzpicture
beginaxis[
width=4cm,
height=4cm,
ymin=-0.1,
ymax=0,
% change number format to `fixed'
yticklabel style=
/pgf/number format/fixed,
% % (optionally change the `precision' to your needs)
% /pgf/number format/precision=2,
,
]
addplot table
5 -0.000535
;
endaxis
endtikzpicture
enddocument


image showing the result of above code







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 13 at 15:12

























answered Aug 13 at 15:04









Stefan Pinnow

18.7k83169




18.7k83169











  • Exactly what i was waiting for as explanation ! Thank you very much
    – Viv
    Aug 14 at 8:24
















  • Exactly what i was waiting for as explanation ! Thank you very much
    – Viv
    Aug 14 at 8:24















Exactly what i was waiting for as explanation ! Thank you very much
– Viv
Aug 14 at 8:24




Exactly what i was waiting for as explanation ! Thank you very much
– Viv
Aug 14 at 8:24










up vote
2
down vote













If you do not need assume math mode=true for this specific tikzpicture, you can pass /pgf/number format/assume math mode=false to the axis environment options or to the tikzpicture environment options to avoid the error.






share|improve this answer




















  • another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
    – Viv
    Aug 8 at 10:35










  • Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
    – BambOo
    Aug 8 at 10:39










  • I dont think this is the reason because the problem appeared with a huge figure ;-)
    – Viv
    Aug 8 at 11:05














up vote
2
down vote













If you do not need assume math mode=true for this specific tikzpicture, you can pass /pgf/number format/assume math mode=false to the axis environment options or to the tikzpicture environment options to avoid the error.






share|improve this answer




















  • another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
    – Viv
    Aug 8 at 10:35










  • Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
    – BambOo
    Aug 8 at 10:39










  • I dont think this is the reason because the problem appeared with a huge figure ;-)
    – Viv
    Aug 8 at 11:05












up vote
2
down vote










up vote
2
down vote









If you do not need assume math mode=true for this specific tikzpicture, you can pass /pgf/number format/assume math mode=false to the axis environment options or to the tikzpicture environment options to avoid the error.






share|improve this answer












If you do not need assume math mode=true for this specific tikzpicture, you can pass /pgf/number format/assume math mode=false to the axis environment options or to the tikzpicture environment options to avoid the error.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 8 at 10:32









BambOo

2,355323




2,355323











  • another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
    – Viv
    Aug 8 at 10:35










  • Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
    – BambOo
    Aug 8 at 10:39










  • I dont think this is the reason because the problem appeared with a huge figure ;-)
    – Viv
    Aug 8 at 11:05
















  • another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
    – Viv
    Aug 8 at 10:35










  • Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
    – BambOo
    Aug 8 at 10:39










  • I dont think this is the reason because the problem appeared with a huge figure ;-)
    – Viv
    Aug 8 at 11:05















another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
– Viv
Aug 8 at 10:35




another good solution in deed ! But i fact i spent one our to understand that the problem was coming from the math mode, i dont really understrand why it behaves like that ...
– Viv
Aug 8 at 10:35












Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
– BambOo
Aug 8 at 10:39




Maybe more advanded users as @marmot could answer that more precisely, but try to plot something almost empty may be the reason...
– BambOo
Aug 8 at 10:39












I dont think this is the reason because the problem appeared with a huge figure ;-)
– Viv
Aug 8 at 11:05




I dont think this is the reason because the problem appeared with a huge figure ;-)
– Viv
Aug 8 at 11:05

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445118%2fylim-with-negative-floating-point-number%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

Confectionery