Menu

Setting Colors

gw1500se
2015-08-19
2015-08-20
  • gw1500se

    gw1500se - 2015-08-19

    I'm having trouble setting my colors. This is the code:

    $plot->SetDataColors(array('black','red','green','blue','purple'));

    Here is my plot array:

    Array
    (
    [0] => Array
    (
    [0] => 2015-08-15
    [1] => 655.8516
    [2] => 163.4172
    [3] => 173.7144
    [4] => 153.6344
    [5] => 165.0856
    )

    [1] => Array
        (
            [0] => 2014-08-16
            [1] => 646.1144
            [2] => 167.9656
            [3] => 154.2516
            [4] => 163.3828
            [5] => 160.5144
        )
    

    )

    The first line is black, the second line is red, the third line is dotted green (where did that come from), the forth line is blue and the fifth line is either white or did not plot at all. What am I doing wrong? TIA.

     
  • lbayuk

    lbayuk - 2015-08-20

    Regarding the dotted line, that is a default in PHPlot that I'm not happy with but don't want to change because of backward compatibility. By default, every third plot line is dashed. To make them all solid: $plot->SetLineStyles('solid').

    What is your data type (SetDataType)? That is, does the 2nd entry in each row of your data array represet X, or Y0?

    If I plot your data with data type 'text-data', I do get 5 lines: black, red, green, blue, purple. The purple is hard to see because it is so close to the others, especially the red line on the left. But I can see them all on the right.

    If I plot your data with data type 'data-data', I now have 4 lines (since the 2nd column is now interpreted as X), using the first 4 of your colors.

     
  • gw1500se

    gw1500se - 2015-08-20

    Thanks. I did not see that 3rd line caveat in the documentation. That's an easy fix. Since the first value is a date then I see where text-data makes more sense. That is the X value and all the rest are Y values. I have another question but I'll create a new thread for it.

     

    Last edit: gw1500se 2015-08-20

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.