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

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

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

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?