Set a diverging color scheme to center on zero in AltairHow to merge two dictionaries in a single expression?Calling an external command in PythonFinding the index of an item given a list containing it in PythonUsing global variables in a functionUnderstanding Python super() with __init__() methodsHow do I sort a dictionary by value?How to make a chain of function decorators?How do I pass a variable by reference?How do I get the number of elements in a list?How do I list all files of a directory?

Did they show Truman doing private things (toilet, etc) when filming him for 24 hours, 7 days a week?

How does the illumination of the sky from the sun compare to that of the moon?

Installing the original OS X version onto a Mac?

!I!n!s!e!r!t! !b!e!t!w!e!e!n!

Installing certbot - error - "nothing provides pyparsing"

Why should I pay for an SSL certificate?

Repurpose telephone line to ethernet

Can I submit a paper computer science conference using an alias if using my real name can cause legal trouble in my original country

Would getting a natural 20 with a penalty still count as a critical hit?

Is there a utility / method to organize trad gear so that each piece is immediately accessible?

Why should P.I be willing to write strong LOR even if that means losing a undergraduate from his/her lab?

Does == actually work the same or different when comparing two primitives vs two Objects in Java?

Virtual destructor moves object out of rodata section

Which basis does the wavefunction collapse to?

The Lucky House

My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?

Does git delete empty folders?

Output with the same length always

Adding things to bunches of things vs multiplication

Outer Class can have how many inner class(es)

What causes burn marks on the air handler in the attic?

From France west coast to Portugal via ship?

What happened after the end of the Truman Show?

Check disk usage of files returned with spaces



Set a diverging color scheme to center on zero in Altair


How to merge two dictionaries in a single expression?Calling an external command in PythonFinding the index of an item given a list containing it in PythonUsing global variables in a functionUnderstanding Python super() with __init__() methodsHow do I sort a dictionary by value?How to make a chain of function decorators?How do I pass a variable by reference?How do I get the number of elements in a list?How do I list all files of a directory?






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








0















How can I go about getting the colour scale to center on zero for a diverging colour scale.










share|improve this question
































    0















    How can I go about getting the colour scale to center on zero for a diverging colour scale.










    share|improve this question




























      0












      0








      0








      How can I go about getting the colour scale to center on zero for a diverging colour scale.










      share|improve this question
















      How can I go about getting the colour scale to center on zero for a diverging colour scale.







      python visualization altair






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 14:12









      jakevdp

      23.5k4 gold badges42 silver badges62 bronze badges




      23.5k4 gold badges42 silver badges62 bronze badges










      asked Mar 27 at 13:58









      EamonnEamonn

      3583 silver badges16 bronze badges




      3583 silver badges16 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          2














          One way to do this is to explicitly set the domain to be symmetric:



          import numpy as np
          import pandas as pd
          import altair as alt

          df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
          alt.Chart(df).mark_point().encode(
          x='x',
          y='y',
          color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
          )


          enter image description here






          share|improve this answer

























          • Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

            – Eamonn
            Mar 27 at 14:14












          • We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

            – kanitw
            Mar 28 at 5:32










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f55379035%2fset-a-diverging-color-scheme-to-center-on-zero-in-altair%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














          One way to do this is to explicitly set the domain to be symmetric:



          import numpy as np
          import pandas as pd
          import altair as alt

          df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
          alt.Chart(df).mark_point().encode(
          x='x',
          y='y',
          color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
          )


          enter image description here






          share|improve this answer

























          • Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

            – Eamonn
            Mar 27 at 14:14












          • We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

            – kanitw
            Mar 28 at 5:32















          2














          One way to do this is to explicitly set the domain to be symmetric:



          import numpy as np
          import pandas as pd
          import altair as alt

          df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
          alt.Chart(df).mark_point().encode(
          x='x',
          y='y',
          color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
          )


          enter image description here






          share|improve this answer

























          • Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

            – Eamonn
            Mar 27 at 14:14












          • We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

            – kanitw
            Mar 28 at 5:32













          2












          2








          2







          One way to do this is to explicitly set the domain to be symmetric:



          import numpy as np
          import pandas as pd
          import altair as alt

          df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
          alt.Chart(df).mark_point().encode(
          x='x',
          y='y',
          color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
          )


          enter image description here






          share|improve this answer













          One way to do this is to explicitly set the domain to be symmetric:



          import numpy as np
          import pandas as pd
          import altair as alt

          df = pd.DataFrame(np.random.randn(100, 3), columns=['x', 'y', 'z'])
          alt.Chart(df).mark_point().encode(
          x='x',
          y='y',
          color=alt.Color('z', scale=alt.Scale(scheme='blueorange', domain=[-3, 3]))
          )


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 14:12









          jakevdpjakevdp

          23.5k4 gold badges42 silver badges62 bronze badges




          23.5k4 gold badges42 silver badges62 bronze badges















          • Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

            – Eamonn
            Mar 27 at 14:14












          • We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

            – kanitw
            Mar 28 at 5:32

















          • Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

            – Eamonn
            Mar 27 at 14:14












          • We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

            – kanitw
            Mar 28 at 5:32
















          Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

          – Eamonn
          Mar 27 at 14:14






          Ah, perfect! Simple solution. I was hoping there would be a center as in seaborn for example, but this also works, although it's a pain if the values are skewed heavily towards either extreme.

          – Eamonn
          Mar 27 at 14:14














          We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

          – kanitw
          Mar 28 at 5:32





          We do plan to add scale.domainMid to Vega-Lite/Altair, but haven't got the time to do it yet. You can follow the thread here github.com/vega/vega-lite/issues/4542. Contributions are also welcomed. :)

          – kanitw
          Mar 28 at 5:32








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f55379035%2fset-a-diverging-color-scheme-to-center-on-zero-in-altair%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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해