karthik84 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks First I would like to thank all of you for answering many peoples question as I learned perl from reading all the posts. I generated a line graph using GD graph. Is there a way I could plot the same line with different color for each section?? For ex. If I have days on x axis and numbers on y axis, I would like the line from Monday to tuesday be in red color, tuesday to wednesday in green color and so on. Is there any way of doing this??
  • Comment on GD graph use different colors for data points

Replies are listed 'Best First'.
Re: GD graph use different colors for data points
by txzaphod (Initiate) on Jul 09, 2008 at 21:02 UTC
    You could try plotting as several different lines, each line with only 2 points, and the last point of the previous line would be the first point of the next line. Each line would use a different color.
      I have multiple data sets in my graph and i do a whole lot of data manipulation in the graph. So plotting as several different lines might complicated. But will give this a try. Thanks guys for the response. Please let me know if there is an easier way.
      Plotting two points at a time will not work as my graph has multiple data sets and I wont be able to correlate the legends with the graph. I am using a different line type for each dataset.
Re: GD graph use different colors for data points
by zentara (Cardinal) on Jul 09, 2008 at 20:23 UTC
    I think you may to go to a canvas widget for something that specialized, but someone may know a way with pure GD. GD::Graph::bars allows a bar graph with different colors.

    I'm not really a human, but I play one on earth CandyGram for Mongo