ValueError(“color kwarg must have one color per dataset”)?









up vote
7
down vote

favorite












I just simply save the data into files and read them out and then draw histogram. However, it appears this mistake though I changed nothing from the original code actually. Could anyone tell me what's wrong? Thanks a lot.



Here is the code for hist()



f_120 = plt.figure(1)
plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
plt.axvline(x = 30, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '30 min')
plt.axvline(x = 60, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 hour')
plt.legend()

plt.ylabel('Percentage of answered questions')
plt.xlabel('Minutes elapsed after questions are posted')
plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 2 hrs)')
plt.ylim(0,1)
plt.xlim(0,120)

f_120.show()

f_2640 = plt.figure(2)
plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
plt.axvline(x = 240, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '4 hours')
plt.axvline(x = 1440, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 day')
plt.legend(loc= 4)

plt.ylabel('Percentage of answered questions')
plt.xlabel('Minutes elapsed after questions are posted')
plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 48)')
plt.ylim(0,1)
plt.xlim(0,2640)

f_2640.show()


And there is the full-text for the error:



 plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step",
cumulative = True, color = 'b',label = 'first answer')

File "C:Python26libsite-packagesmatplotlibpyplot.py", line 2160, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype,
align, orientation, rwidth, log, color, label, **kwargs)

File "C:Python26libsite-packagesmatplotlibaxes.py", line 7606, in hist
raise ValueError("color kwarg must have one color per dataset")

ValueError: color kwarg must have one color per dataset









share|improve this question



























    up vote
    7
    down vote

    favorite












    I just simply save the data into files and read them out and then draw histogram. However, it appears this mistake though I changed nothing from the original code actually. Could anyone tell me what's wrong? Thanks a lot.



    Here is the code for hist()



    f_120 = plt.figure(1)
    plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
    plt.axvline(x = 30, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '30 min')
    plt.axvline(x = 60, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 hour')
    plt.legend()

    plt.ylabel('Percentage of answered questions')
    plt.xlabel('Minutes elapsed after questions are posted')
    plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 2 hrs)')
    plt.ylim(0,1)
    plt.xlim(0,120)

    f_120.show()

    f_2640 = plt.figure(2)
    plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
    plt.axvline(x = 240, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '4 hours')
    plt.axvline(x = 1440, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 day')
    plt.legend(loc= 4)

    plt.ylabel('Percentage of answered questions')
    plt.xlabel('Minutes elapsed after questions are posted')
    plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 48)')
    plt.ylim(0,1)
    plt.xlim(0,2640)

    f_2640.show()


    And there is the full-text for the error:



     plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step",
    cumulative = True, color = 'b',label = 'first answer')

    File "C:Python26libsite-packagesmatplotlibpyplot.py", line 2160, in hist
    ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype,
    align, orientation, rwidth, log, color, label, **kwargs)

    File "C:Python26libsite-packagesmatplotlibaxes.py", line 7606, in hist
    raise ValueError("color kwarg must have one color per dataset")

    ValueError: color kwarg must have one color per dataset









    share|improve this question

























      up vote
      7
      down vote

      favorite









      up vote
      7
      down vote

      favorite











      I just simply save the data into files and read them out and then draw histogram. However, it appears this mistake though I changed nothing from the original code actually. Could anyone tell me what's wrong? Thanks a lot.



      Here is the code for hist()



      f_120 = plt.figure(1)
      plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
      plt.axvline(x = 30, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '30 min')
      plt.axvline(x = 60, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 hour')
      plt.legend()

      plt.ylabel('Percentage of answered questions')
      plt.xlabel('Minutes elapsed after questions are posted')
      plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 2 hrs)')
      plt.ylim(0,1)
      plt.xlim(0,120)

      f_120.show()

      f_2640 = plt.figure(2)
      plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
      plt.axvline(x = 240, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '4 hours')
      plt.axvline(x = 1440, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 day')
      plt.legend(loc= 4)

      plt.ylabel('Percentage of answered questions')
      plt.xlabel('Minutes elapsed after questions are posted')
      plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 48)')
      plt.ylim(0,1)
      plt.xlim(0,2640)

      f_2640.show()


      And there is the full-text for the error:



       plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step",
      cumulative = True, color = 'b',label = 'first answer')

      File "C:Python26libsite-packagesmatplotlibpyplot.py", line 2160, in hist
      ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype,
      align, orientation, rwidth, log, color, label, **kwargs)

      File "C:Python26libsite-packagesmatplotlibaxes.py", line 7606, in hist
      raise ValueError("color kwarg must have one color per dataset")

      ValueError: color kwarg must have one color per dataset









      share|improve this question















      I just simply save the data into files and read them out and then draw histogram. However, it appears this mistake though I changed nothing from the original code actually. Could anyone tell me what's wrong? Thanks a lot.



      Here is the code for hist()



      f_120 = plt.figure(1)
      plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
      plt.axvline(x = 30, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '30 min')
      plt.axvline(x = 60, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 hour')
      plt.legend()

      plt.ylabel('Percentage of answered questions')
      plt.xlabel('Minutes elapsed after questions are posted')
      plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 2 hrs)')
      plt.ylim(0,1)
      plt.xlim(0,120)

      f_120.show()

      f_2640 = plt.figure(2)
      plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step", cumulative = True, color = 'g',label = 'first answer')
      plt.axvline(x = 240, ymin = 0, ymax = 1, color = 'r', linestyle = '--', label = '4 hours')
      plt.axvline(x = 1440, ymin = 0, ymax = 1, color = 'c', linestyle = '--', label = '1 day')
      plt.legend(loc= 4)

      plt.ylabel('Percentage of answered questions')
      plt.xlabel('Minutes elapsed after questions are posted')
      plt.title('Cumulative histogram: time elapsed n before questions receive answer (first 48)')
      plt.ylim(0,1)
      plt.xlim(0,2640)

      f_2640.show()


      And there is the full-text for the error:



       plt.hist(tfirst_list, bins=6000000, normed = True, histtype ="step",
      cumulative = True, color = 'b',label = 'first answer')

      File "C:Python26libsite-packagesmatplotlibpyplot.py", line 2160, in hist
      ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype,
      align, orientation, rwidth, log, color, label, **kwargs)

      File "C:Python26libsite-packagesmatplotlibaxes.py", line 7606, in hist
      raise ValueError("color kwarg must have one color per dataset")

      ValueError: color kwarg must have one color per dataset






      python matplotlib






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 13 '11 at 16:39









      phihag

      192k47359401




      192k47359401










      asked Oct 13 '11 at 16:35









      AnneS

      5033818




      5033818






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          10
          down vote



          accepted










          This problem is because you have defined tfirst_list as a N-dimensional array.

          For example:



          tfirst_list = [1, 2, 3, 4, 5, 6, 7, 8] #works
          tfirst_list = [[1, 2, 3, 4], [5, 6, 7, 8]] #produces the Exception you have


          If you are using N-dimensional data (N datasets), then the color keyword argument (color kwarg) must be also N-dimensional (one color per dataset). For example for the case above:



          color = ['b', 'r']





          share|improve this answer






















            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',
            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%2f7757386%2fvalueerrorcolor-kwarg-must-have-one-color-per-dataset%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








            up vote
            10
            down vote



            accepted










            This problem is because you have defined tfirst_list as a N-dimensional array.

            For example:



            tfirst_list = [1, 2, 3, 4, 5, 6, 7, 8] #works
            tfirst_list = [[1, 2, 3, 4], [5, 6, 7, 8]] #produces the Exception you have


            If you are using N-dimensional data (N datasets), then the color keyword argument (color kwarg) must be also N-dimensional (one color per dataset). For example for the case above:



            color = ['b', 'r']





            share|improve this answer


























              up vote
              10
              down vote



              accepted










              This problem is because you have defined tfirst_list as a N-dimensional array.

              For example:



              tfirst_list = [1, 2, 3, 4, 5, 6, 7, 8] #works
              tfirst_list = [[1, 2, 3, 4], [5, 6, 7, 8]] #produces the Exception you have


              If you are using N-dimensional data (N datasets), then the color keyword argument (color kwarg) must be also N-dimensional (one color per dataset). For example for the case above:



              color = ['b', 'r']





              share|improve this answer
























                up vote
                10
                down vote



                accepted







                up vote
                10
                down vote



                accepted






                This problem is because you have defined tfirst_list as a N-dimensional array.

                For example:



                tfirst_list = [1, 2, 3, 4, 5, 6, 7, 8] #works
                tfirst_list = [[1, 2, 3, 4], [5, 6, 7, 8]] #produces the Exception you have


                If you are using N-dimensional data (N datasets), then the color keyword argument (color kwarg) must be also N-dimensional (one color per dataset). For example for the case above:



                color = ['b', 'r']





                share|improve this answer














                This problem is because you have defined tfirst_list as a N-dimensional array.

                For example:



                tfirst_list = [1, 2, 3, 4, 5, 6, 7, 8] #works
                tfirst_list = [[1, 2, 3, 4], [5, 6, 7, 8]] #produces the Exception you have


                If you are using N-dimensional data (N datasets), then the color keyword argument (color kwarg) must be also N-dimensional (one color per dataset). For example for the case above:



                color = ['b', 'r']






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Oct 13 '11 at 18:53

























                answered Oct 13 '11 at 17:00









                joaquin

                53k21123138




                53k21123138



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7757386%2fvalueerrorcolor-kwarg-must-have-one-color-per-dataset%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

                    Darth Vader #20

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Ondo