PDA

View Full Version : Histogram: Changing the color of one specific balk



Agfels
31st August 2010, 10:05
Hello folks,

I have an histogram having eaxctly 7 balk with the green color for all balk, but i am looking for a way on how to paint (e.g. blue) only and only one balk for a specific reasons. This is important for me in order to show specific details. my code:

QwtPlot plot;
plot.setCanvasBackground(QColor(Qt::black));
plot.setTitle("Histogram: Test Diagram ");

QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->enableYMin(true);
grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0, Qt::DotLine));
grid->attach(&plot);
....
....
....
plot.setAxisTitle(QwtPlot::yLeft, " number ");
plot.setAxisScale(QwtPlot::yLeft, 0.0, DATA_NUMBER);
plot.setAxisTitle(QwtPlot::xBottom, " <- Datatypen -> ");

plot.setAxisScaleDraw(QwtPlot::xBottom, new DataScaleDraw());
plot.setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
plot.setAxisScale(QwtPlot::xBottom, 0.0, DATA_TYPE_NUMBER);
plot.setAxisMaxMinor(QwtPlot::xBottom, 0);

Note: DataScaleDraw() is following:

class DataScaleDraw: public QwtScaleDraw
{
public:
DataScaleDraw()
{
}
virtual QwtText label(double v) const
{
switch (int(v))
{ case 1: return QString(" PP "); break;
case 2: return QString(" AP "); break;
case 3: return QString(" PM "); break;
case 4: return QString(" FM "); break;
case 5: return QString(" DD "); break;
case 6: return QString(" SS "); break;
case 7: return QString(" GG "); break;
}

return QwtScaleDraw::label(v);
}
};

Uwe
31st August 2010, 14:33
At least you have to tell us what type of plot item you are using to display your histogram.

Uwe

PS: What is the point behind the poll ?

Agfels
31st August 2010, 16:01
Uwe

Many thanks, but I am sorry for having small skills with Qwt. My Histogram class is derived from QwtPoltItem (This class was taken out from the qwt examples, the only change were my own DataScaledraw class).
...
...
HistogramItem *histogram = new HistogramItem();
histogram->setColor(Qt::darkGreen);
...

The Point behind the poll is following:
My Histogram describes a statistical spreading for a specific measurements, but for a given component with a higher frequency of occurence within the Histogram, I have to highly this by using another color within the histogram. For example, I have 7 measurements components, by which 6 components has x+i frequency of occurence. All those are represented into my Histogram with green balk. okay. However the component with the higher value of frequency must be displayed into the same Histogram with another color(e.g. blue).

Thanks in advance.

Uwe
31st August 2010, 16:47
My Histogram class is derived from QwtPoltItem (This class was taken out from the qwt examples
Well, this example shows how you could implement a histogram. If you want to go with it you have to understand and modify it ( what isn't to hard, when you have more than only very basic Qt know how ).

Otherwise use Qwt from SVN trunk. It includes a new plot item called QwtPlotHistogram.


The Point behind the poll is following:
This explains your posting, but not a poll.

Uwe

Agfels
8th September 2010, 14:39
Thanks Uwe,

could you please point me (e.g. URL name) on how to get access to this trunk via TortoisesSVN ? I need this new Histogramm class absolutely.

Thanks