Results 1 to 2 of 2

Thread: QwtPlot with multiple QwtPlotCurves all with different colors?

  1. #1
    Join Date
    Jun 2011
    Qt products
    MacOS X

    Default QwtPlot with multiple QwtPlotCurves all with different colors?

    I have a my own Plot class which has a function to create PlotCurves based upon x and y values that are passed in contained in vectors and a vector that holds index's of where each Curve ends and the next one begins. Since this is all happening in a for loop I need something like a ColorMap that I can grab a new color from every time for the pen color. I have been looking at QwtLinearColorMap but it doesn't seem to have the functionality I desire. I can access the amount of curves that are going to be plotted based upon the vector of index's size() function but I need a way to make each curve have a different color for any amount of curves.

  2. #2
    Join Date
    Oct 2010
    Berlin, Germany
    Thanked 68 Times in 66 Posts
    Qt products

    Default Re: QwtPlot with multiple QwtPlotCurves all with different colors?

    first: you can't have a unique color for any amount of curves. the RGB-format does not support more than 16,7 million colors

    You could use QColors methods darker(int factor) and lighter(int). You start with a color and in each loop you change it. I suggest switching between darker and lighter each loop otherwise the color would get completely white/black after some loops...
    You could calculate colors on-the-fly based on the current loop-index, maybe combined with darker/lighter.
    You could define a huge array which contains different QColors.

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 16:26
  2. Replies: 1
    Last Post: 13th March 2010, 08:55
  3. Replies: 1
    Last Post: 13th January 2010, 17:21
  4. Replies: 1
    Last Post: 16th April 2009, 16:12
  5. Replies: 10
    Last Post: 18th September 2008, 15:14

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.