Dear all,

I have the following problem. I would like to visualize a two-dimensional grid in which agents move. They all have a certain value which I like to visualize using colours, that is why I like to use QwtPlotSpectrogram. However, after reading various examples and implementing code, my grid stays gray, and none of the colours are displayed.

This is my code:

In the constructor of mainwindow.cpp:

Qt Code:
  1. //Colormap
  2. colormap = new QwtLinearColorMap(Qt::darkCyan, Qt::red);
  3. colormap->addColorStop(0.1, Qt::cyan);
  4. colormap->addColorStop(0.6, Qt::green);
  5. colormap->addColorStop(0.95, Qt::yellow); //empty paradigm different color from all other paradigms
  6.  
  7. //Grid
  8. grid_qwtSpectPLot = new QwtPlotSpectrogram;
  9. grid_qwtSpectPLot->attach(ui->grid_qwtPlot);
  10. grid_qwtSpectPLot->setDisplayMode(QwtPlotSpectrogram::ImageMode, true);
  11. grid_qwtSpectPLot->setColorMap(colormap);
  12. grid_qwtSpectPLot->setRenderThreadCount(0);
  13.  
  14. //Matrix
  15. matrixdata = new QwtMatrixRasterData;
  16. matrixdata->setInterval(Qt::XAxis,QwtInterval(0,99,QwtInterval::IncludeBorders));
  17. matrixdata->setInterval(Qt::YAxis,QwtInterval(0,99,QwtInterval::IncludeBorders));
  18.  
  19. grid_qwtSpectPLot->attach(ui->grid_qwtPlot);
  20. ui->grid_qwtPlot->setTitle(QString("Grid"));
  21. ui->grid_qwtPlot->plotLayout()->setAlignCanvasToScales(true);
To copy to clipboard, switch view to plain text mode 

And two methods which are called during the simulation. Nigel_DeJong is the object which represents the agents on a grid and maxvalue makes sure the values are between 0 and 1. grid is a QVector consisting out of doubles.
Qt Code:
  1. //Get the data to display the grid
  2. void MainWindow::getDataGrid()
  3. {
  4. int l=0;
  5. for(int j=0; j<L; j++){
  6. for(int k=0; k<L; k++){
  7. grid.append(float(Nigel_DeJong->get_value)/maxvalue);
  8. l++;
  9. }
  10. }
  11. }
  12.  
  13. //Update the grid
  14. void MainWindow::viewGrid()
  15. {
  16. getDataGrid();
  17. matrixdata->setValueMatrix(grid,L);
  18. grid_qwtSpectPLot->setData(matrixdata);
  19. ui->grid_qwtPlot->replot();
  20. grid.clear();
  21. }
To copy to clipboard, switch view to plain text mode 

I checked the values in the matrix, and it is filled with doubles between 0 and 1. Does anyone see what results in a completely grey grid?

Much thanks in advance.