Keep zero in the centre of axisplotting two time series with boundsHow do i get the x axis on top but keep a line on the bottomAxis labels shifts off centre when using the xscale functionKeep position of coordinates with different axis-scaleHow to hide empty (value 0) ybars with pgfplots?pgfplots: percentage in matrix plotPlacing a zero in a pgfplots with middle axisnon linear scaling of y-axis around zeroKeep path within axis

What is the motivation behind designing a control stick that does not move?

In what language did Túrin converse with Mím?

Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?

Is it good practice to speed up and slow down where not written in a song?

Power supply circuit for a PIC16F88 Microchip

Tikz: Draw simplified BLE-Stack

Where should I draw the line on follow up questions from previous employer

Using font to highlight a god's speech in dialogue

Could a simple hospital oxygen mask protect from aerosol poison?

Can a human variant take proficiency in initiative?

Padding a column of lists

Welche normative Autorität hat der Duden? / What's the normative authority of the Duden?

How to Flip Rotation from Positive to Negative?

Is the following statement true: two real numbers a and b are equal iff for every ε > 0, |a − b| < ε.

I failed to respond to a potential advisor

How is the anglicism "jackpot" commonly expressed in French?

How does the search space affect the speed of an ILP solver?

How to investigate an unknown 1.5GB file named "sudo" in my Linux home directory?

How were US credit cards verified in-store in the 1980's?

Does FERPA require parental notification of disability assessment?

I was given someone else's visa, stamped in my passport

How would a disabled person earn their living in a medieval-type town?

Can two aircraft be allowed to stay on the same runway at the same time?

Can a system of three stars exist?



Keep zero in the centre of axis


plotting two time series with boundsHow do i get the x axis on top but keep a line on the bottomAxis labels shifts off centre when using the xscale functionKeep position of coordinates with different axis-scaleHow to hide empty (value 0) ybars with pgfplots?pgfplots: percentage in matrix plotPlacing a zero in a pgfplots with middle axisnon linear scaling of y-axis around zeroKeep path within axis






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I want to understand if I can keep the x axis automatically "centred" around 0, i.e., having the absolute axis option values for x min and x max equal, without setting them explicitly.



The following MWE shows the issue. I have point estimates and their confidence intervals. The maximum values are -3.5 and 3.5, however, setting those to x min or x max would decrease the readability (shrink the plots).
On the other hand, comparing the point estimates would be easier if the zero was centred.



MWE:



documentclassarticle

usepackagepgfplots

beginfilecontentsdata.csv
nr est CL CU
1 -0.9 -1.3 -0.3
2 0 -0.6 0.58
endfilecontents

begindocument

begintikzpicture
beginaxis[xmajorgrids]
addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
x=est,
y = nr,
x error plus expr=thisrowCU-thisrowest,
x error minus expr=thisrowest-thisrowCL]data.csv;
endaxis
endtikzpicture

enddocument


Point estimates and their confidence intervals, without being centred.










share|improve this question






























    3















    I want to understand if I can keep the x axis automatically "centred" around 0, i.e., having the absolute axis option values for x min and x max equal, without setting them explicitly.



    The following MWE shows the issue. I have point estimates and their confidence intervals. The maximum values are -3.5 and 3.5, however, setting those to x min or x max would decrease the readability (shrink the plots).
    On the other hand, comparing the point estimates would be easier if the zero was centred.



    MWE:



    documentclassarticle

    usepackagepgfplots

    beginfilecontentsdata.csv
    nr est CL CU
    1 -0.9 -1.3 -0.3
    2 0 -0.6 0.58
    endfilecontents

    begindocument

    begintikzpicture
    beginaxis[xmajorgrids]
    addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
    x=est,
    y = nr,
    x error plus expr=thisrowCU-thisrowest,
    x error minus expr=thisrowest-thisrowCL]data.csv;
    endaxis
    endtikzpicture

    enddocument


    Point estimates and their confidence intervals, without being centred.










    share|improve this question


























      3












      3








      3








      I want to understand if I can keep the x axis automatically "centred" around 0, i.e., having the absolute axis option values for x min and x max equal, without setting them explicitly.



      The following MWE shows the issue. I have point estimates and their confidence intervals. The maximum values are -3.5 and 3.5, however, setting those to x min or x max would decrease the readability (shrink the plots).
      On the other hand, comparing the point estimates would be easier if the zero was centred.



      MWE:



      documentclassarticle

      usepackagepgfplots

      beginfilecontentsdata.csv
      nr est CL CU
      1 -0.9 -1.3 -0.3
      2 0 -0.6 0.58
      endfilecontents

      begindocument

      begintikzpicture
      beginaxis[xmajorgrids]
      addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
      x=est,
      y = nr,
      x error plus expr=thisrowCU-thisrowest,
      x error minus expr=thisrowest-thisrowCL]data.csv;
      endaxis
      endtikzpicture

      enddocument


      Point estimates and their confidence intervals, without being centred.










      share|improve this question














      I want to understand if I can keep the x axis automatically "centred" around 0, i.e., having the absolute axis option values for x min and x max equal, without setting them explicitly.



      The following MWE shows the issue. I have point estimates and their confidence intervals. The maximum values are -3.5 and 3.5, however, setting those to x min or x max would decrease the readability (shrink the plots).
      On the other hand, comparing the point estimates would be easier if the zero was centred.



      MWE:



      documentclassarticle

      usepackagepgfplots

      beginfilecontentsdata.csv
      nr est CL CU
      1 -0.9 -1.3 -0.3
      2 0 -0.6 0.58
      endfilecontents

      begindocument

      begintikzpicture
      beginaxis[xmajorgrids]
      addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
      x=est,
      y = nr,
      x error plus expr=thisrowCU-thisrowest,
      x error minus expr=thisrowest-thisrowCL]data.csv;
      endaxis
      endtikzpicture

      enddocument


      Point estimates and their confidence intervals, without being centred.







      pgfplots






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      MarcusMarcus

      2612 silver badges11 bronze badges




      2612 silver badges11 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          2















          I am not sure if there is an automatic solution since pgfkeysvalueof/pgfplots/xmin and pgfkeysvalueof/pgfplots/xmax won't be set but it is easy to infer the actual values of xmin and xmax using calc. They can be used in the final plot.



          documentclassarticle
          usepackagefilecontents
          beginfilecontents*data.csv
          nr est CL CU
          1 -0.9 -1.3 -0.3
          2 0 -0.6 0.58
          endfilecontents*
          usepackagepgfplots
          usetikzlibrarycalc
          pgfplotssetcompat=1.16

          begindocument
          Step 1: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.

          begintikzpicture
          beginaxis[xmajorgrids]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          path (0,0) coordinate (O) (1,0) coordinate(X);
          endaxis
          path let p1=($(current axis.west)-(O)$),p2=($(current axis.east)-(O)$),
          p3=($(X)-(O)$) in
          pgfextrapgfmathsetmacromyxminx1/x3%
          pgfmathsetmacromyxmaxx2/x3%
          messagexmin=myxmin, xmax=myxmax^^J%
          pgfmathsetmacronewxmin-1*max(abs(myxmin),abs(myxmax))%
          xdefnewxminnewxmin%
          pgfmathsetmacronewxmaxmax(abs(myxmin),abs(myxmax))%
          xdefnewxmaxnewxmax;
          endtikzpicture

          Step 2: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.


          begintikzpicture
          beginaxis[xmajorgrids,xmin=-1.488,xmax=1.488]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          clearpage
          You can also use the computed values.

          begintikzpicture
          beginaxis[xmajorgrids,xmin=newxmin,xmax=newxmax]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          enddocument


          enter image description here



          You may make it fully automatic by writing the inferred values to the aux file. I will be happy to spell this out if needed.






          share|improve this answer

























          • Of course one also put the trial plot in a savebox.

            – Schrödinger's cat
            3 hours ago













          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%2f506472%2fkeep-zero-in-the-centre-of-axis%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















          I am not sure if there is an automatic solution since pgfkeysvalueof/pgfplots/xmin and pgfkeysvalueof/pgfplots/xmax won't be set but it is easy to infer the actual values of xmin and xmax using calc. They can be used in the final plot.



          documentclassarticle
          usepackagefilecontents
          beginfilecontents*data.csv
          nr est CL CU
          1 -0.9 -1.3 -0.3
          2 0 -0.6 0.58
          endfilecontents*
          usepackagepgfplots
          usetikzlibrarycalc
          pgfplotssetcompat=1.16

          begindocument
          Step 1: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.

          begintikzpicture
          beginaxis[xmajorgrids]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          path (0,0) coordinate (O) (1,0) coordinate(X);
          endaxis
          path let p1=($(current axis.west)-(O)$),p2=($(current axis.east)-(O)$),
          p3=($(X)-(O)$) in
          pgfextrapgfmathsetmacromyxminx1/x3%
          pgfmathsetmacromyxmaxx2/x3%
          messagexmin=myxmin, xmax=myxmax^^J%
          pgfmathsetmacronewxmin-1*max(abs(myxmin),abs(myxmax))%
          xdefnewxminnewxmin%
          pgfmathsetmacronewxmaxmax(abs(myxmin),abs(myxmax))%
          xdefnewxmaxnewxmax;
          endtikzpicture

          Step 2: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.


          begintikzpicture
          beginaxis[xmajorgrids,xmin=-1.488,xmax=1.488]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          clearpage
          You can also use the computed values.

          begintikzpicture
          beginaxis[xmajorgrids,xmin=newxmin,xmax=newxmax]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          enddocument


          enter image description here



          You may make it fully automatic by writing the inferred values to the aux file. I will be happy to spell this out if needed.






          share|improve this answer

























          • Of course one also put the trial plot in a savebox.

            – Schrödinger's cat
            3 hours ago















          2















          I am not sure if there is an automatic solution since pgfkeysvalueof/pgfplots/xmin and pgfkeysvalueof/pgfplots/xmax won't be set but it is easy to infer the actual values of xmin and xmax using calc. They can be used in the final plot.



          documentclassarticle
          usepackagefilecontents
          beginfilecontents*data.csv
          nr est CL CU
          1 -0.9 -1.3 -0.3
          2 0 -0.6 0.58
          endfilecontents*
          usepackagepgfplots
          usetikzlibrarycalc
          pgfplotssetcompat=1.16

          begindocument
          Step 1: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.

          begintikzpicture
          beginaxis[xmajorgrids]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          path (0,0) coordinate (O) (1,0) coordinate(X);
          endaxis
          path let p1=($(current axis.west)-(O)$),p2=($(current axis.east)-(O)$),
          p3=($(X)-(O)$) in
          pgfextrapgfmathsetmacromyxminx1/x3%
          pgfmathsetmacromyxmaxx2/x3%
          messagexmin=myxmin, xmax=myxmax^^J%
          pgfmathsetmacronewxmin-1*max(abs(myxmin),abs(myxmax))%
          xdefnewxminnewxmin%
          pgfmathsetmacronewxmaxmax(abs(myxmin),abs(myxmax))%
          xdefnewxmaxnewxmax;
          endtikzpicture

          Step 2: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.


          begintikzpicture
          beginaxis[xmajorgrids,xmin=-1.488,xmax=1.488]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          clearpage
          You can also use the computed values.

          begintikzpicture
          beginaxis[xmajorgrids,xmin=newxmin,xmax=newxmax]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          enddocument


          enter image description here



          You may make it fully automatic by writing the inferred values to the aux file. I will be happy to spell this out if needed.






          share|improve this answer

























          • Of course one also put the trial plot in a savebox.

            – Schrödinger's cat
            3 hours ago













          2














          2










          2









          I am not sure if there is an automatic solution since pgfkeysvalueof/pgfplots/xmin and pgfkeysvalueof/pgfplots/xmax won't be set but it is easy to infer the actual values of xmin and xmax using calc. They can be used in the final plot.



          documentclassarticle
          usepackagefilecontents
          beginfilecontents*data.csv
          nr est CL CU
          1 -0.9 -1.3 -0.3
          2 0 -0.6 0.58
          endfilecontents*
          usepackagepgfplots
          usetikzlibrarycalc
          pgfplotssetcompat=1.16

          begindocument
          Step 1: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.

          begintikzpicture
          beginaxis[xmajorgrids]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          path (0,0) coordinate (O) (1,0) coordinate(X);
          endaxis
          path let p1=($(current axis.west)-(O)$),p2=($(current axis.east)-(O)$),
          p3=($(X)-(O)$) in
          pgfextrapgfmathsetmacromyxminx1/x3%
          pgfmathsetmacromyxmaxx2/x3%
          messagexmin=myxmin, xmax=myxmax^^J%
          pgfmathsetmacronewxmin-1*max(abs(myxmin),abs(myxmax))%
          xdefnewxminnewxmin%
          pgfmathsetmacronewxmaxmax(abs(myxmin),abs(myxmax))%
          xdefnewxmaxnewxmax;
          endtikzpicture

          Step 2: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.


          begintikzpicture
          beginaxis[xmajorgrids,xmin=-1.488,xmax=1.488]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          clearpage
          You can also use the computed values.

          begintikzpicture
          beginaxis[xmajorgrids,xmin=newxmin,xmax=newxmax]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          enddocument


          enter image description here



          You may make it fully automatic by writing the inferred values to the aux file. I will be happy to spell this out if needed.






          share|improve this answer













          I am not sure if there is an automatic solution since pgfkeysvalueof/pgfplots/xmin and pgfkeysvalueof/pgfplots/xmax won't be set but it is easy to infer the actual values of xmin and xmax using calc. They can be used in the final plot.



          documentclassarticle
          usepackagefilecontents
          beginfilecontents*data.csv
          nr est CL CU
          1 -0.9 -1.3 -0.3
          2 0 -0.6 0.58
          endfilecontents*
          usepackagepgfplots
          usetikzlibrarycalc
          pgfplotssetcompat=1.16

          begindocument
          Step 1: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.

          begintikzpicture
          beginaxis[xmajorgrids]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          path (0,0) coordinate (O) (1,0) coordinate(X);
          endaxis
          path let p1=($(current axis.west)-(O)$),p2=($(current axis.east)-(O)$),
          p3=($(X)-(O)$) in
          pgfextrapgfmathsetmacromyxminx1/x3%
          pgfmathsetmacromyxmaxx2/x3%
          messagexmin=myxmin, xmax=myxmax^^J%
          pgfmathsetmacronewxmin-1*max(abs(myxmin),abs(myxmax))%
          xdefnewxminnewxmin%
          pgfmathsetmacronewxmaxmax(abs(myxmin),abs(myxmax))%
          xdefnewxmaxnewxmax;
          endtikzpicture

          Step 2: measure the $x_mathrmmin$ and $x_mathrmmax$ used in the plot.


          begintikzpicture
          beginaxis[xmajorgrids,xmin=-1.488,xmax=1.488]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          clearpage
          You can also use the computed values.

          begintikzpicture
          beginaxis[xmajorgrids,xmin=newxmin,xmax=newxmax]
          addplot+[only marks,error bars/.cd,x explicit,x dir=both] table [
          x=est,
          y = nr,
          x error plus expr=thisrowCU-thisrowest,
          x error minus expr=thisrowest-thisrowCL]data.csv;
          endaxis
          endtikzpicture

          enddocument


          enter image description here



          You may make it fully automatic by writing the inferred values to the aux file. I will be happy to spell this out if needed.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          Schrödinger's catSchrödinger's cat

          3,6715 silver badges15 bronze badges




          3,6715 silver badges15 bronze badges















          • Of course one also put the trial plot in a savebox.

            – Schrödinger's cat
            3 hours ago

















          • Of course one also put the trial plot in a savebox.

            – Schrödinger's cat
            3 hours ago
















          Of course one also put the trial plot in a savebox.

          – Schrödinger's cat
          3 hours ago





          Of course one also put the trial plot in a savebox.

          – Schrödinger's cat
          3 hours ago

















          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%2f506472%2fkeep-zero-in-the-centre-of-axis%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

          Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

          The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

          19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу