Plot data stored in a hashmap
Hey!
I want to draw a 2D-histogram, i.e. a scatter plot with different intensity values for every point. I am not quite sure whether I understand the hierarchy of Qwt correctly, and because there is a lot of inheritance in my case, I decided to seek your advice.
I store the data which has to be drawn in a hash table, keys are (x,y)-pairs, values are the intensities which shall be displayed in different colors on the plot. I want to efficiently access the Google’s DenseHashMap & avoid conversion from a hash map into a vector. So, my problem is to plot data stored in a hash map.
I thought I’d inherit QwtSeriesData<QwtPoint3D> template class & implement QwtPoint3D sample(size_t i) const member function (SeriesData : QwtSeriesData<QwtPoint3D>), my hash table is contained inside this class. I create a plot item Series : public QwtPlotSeriesItem<QwtPoint3D> & implement draw() & drawSeries() methods. Series shall contain data in a SeriesData container. In the draw method, I shall change the pen color depending on the intensity of the QwtPoint3D.
Does this sound plausible to you? Do you see a better way to do this? I am really not sure in the hierarchy of Qwt & I want to be on the safe side before I run into dead-end and spend days trying to refactor the B.
Thanks in advance!
Re: Plot data stored in a hashmap
Quote:
I thought I’d inherit QwtSeriesData<QwtPoint3D> template class & implement QwtPoint3D sample(size_t i) const member function (SeriesData : QwtSeriesData<QwtPoint3D>), my hash table is contained inside this class.
Yep, all you need to take care of is that you have a fast implementation of sample(). It might help to use the fact, that it is usually called one by one in increasing order.
Quote:
I create a plot item Series : public QwtPlotSeriesItem<QwtPoint3D> & implement draw() & drawSeries() methods. Series shall contain data in a SeriesData container. In the draw method, I shall change the pen color depending on the intensity of the QwtPoint3D.
This is exactly what QwtPlotSpectroCurve does.
Uwe
Re: Plot data stored in a hashmap
Thanks Uwe, for the invaluable insight! My primary implementation of sample() iterated to the item i from the beginning of the hash table. That implementation took 2 minutes to load the whole series! With a floating iterator which stores its previous position and for each new call of sample() moves one step to front, 200 000 series points are loaded in only a few hundredth of a second!
Thanks!