Menu

Need to change the color of each bar

Foos Man
2008-12-12
2012-09-07
  • Foos Man

    Foos Man - 2008-12-12

    Hello everyone,

    I'm trying to create a graph given the date and a number. When I plot it as a bar graph, it plots the bars right, but how can I make each bar a different color (the SetDataColors doesn't work for this)?

    So given:

    array(array("2008-11-06", 401),
    array("2008-11-13",337),
    array("2008-11-20",243),
    array("2008-11-27",289),
    array("2008-12-04",456),
    array("2008-12-11",465));

    How can each date be a different color?

    Thank you for your time.

     
    • lbayuk

      lbayuk - 2008-12-13

      This has come up several times before (search the forum for "color bars"), but the answer is no, there is no way to do this at present. Colors distinguish bars within a group, but corresponding bars in each group have the same color. You can play some tricks by shifting each bar to another group to get different colors, but it doesn't look so good because the bars are offset.

      I think a patch was submitted at one time, but I turned it down because it would not be compatible with existing uses of PHPlot. Also I'm not convinced it is a valid feature in terms of graphical representation of data.

       
  • stanislav

    stanislav - 2010-02-09

    Hi,

    "OWN COLOR FOR EACH BAR" is very neccessary feature for graphical
    representation. Before I met PHPlot, i tried to use pChart, libchart, but they
    don't have this feature. As I can see, this feature is realized in JpGraph
    (ttp://jpgraph.intellit.nl/index.php?topic=4477.0). I hope you will pay
    attention to this problem in future. Thanks.

     
  • lbayuk

    lbayuk - 2010-02-09

    "OWN COLOR FOR EACH BAR" is very neccessary feature for graphical
    representation.

    More information, please? A reference? I'm looking for more than saying it is
    a necessary feature. What is the purpose of the colors that vary for each bar?

    Would you use this only for bar charts with one bar per group, or with
    multiple bars per group too? How would this work with a plot legend, which
    shows the bars in each group by color, if the color varies for different X
    values?

     

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.