Need fast c++ qt/qwt scatter plot - c++

I have a huge array of 2D points (about 3 millions of pairs), which I need to render with reasonable speed in a Qt-based application.
I've tried using QGraphicsScene, but its very slow even on 400000 primitives, so I was looking into the qwt library instead.
It has a scatter plot example screenshot on its sourceforge page, which looks like exactly what I need, but I cannot find neither any kind of actual code that can be used for this data, nor an according API in qwt docs - it mentions only different types of curves.
So it would be good to get some pointers for scatter plot examples and some advice on its performance.
Suggestions for other c++ qt-compatible plotting libraries which can cope with this amount of data are also welcome.

Scatter plot is contained in the "realtime" example: what you want is the IncrementalPlot class.
I'd also suggest that drawing all the 3 million points isn't reasonable, since modern screens have only about 2 million pixels :) Thus it seems better to simplify the plot beforehand by merging the adjacent points into one with a threshold dependent on the zoom factor.

As viens pointed out, generating scatter plots with 3 million points is probably not a good idea.
I have achieved good performance generating 3D scatter plots with 30.000 points using OpenGL.
OpenGL is fast and integrates well with Qt. However, it is a low level API that forces you to do a lot of tedious coding.
VTK may be another option.

MathGL is free (GPL) cross-platform plotting library. It was written in C++ and have Qt widget. Also it is rather fast, but 3 millions points ... it take about 30 seconds to plot in my laptop.

You'd suggest using OpenGL as #vines said, and in particular exploiting or display lists glGenList or vertex buffers. Some million points as primitives vertices shouldn't be that difficult.

Related

drawing time series of millions of vertices using OpenGL

I'm working on a data visualisation application where I need to draw about 20 different time series overlayed in 2D, each consisting of a few million data points. I need to be able to zoom and pan the data left and right to look at it and need to be able to place cursors on the data for measuring time intervals and to inspect data points. It's very important that when zoomed out all the way, I can easily spot outliers in the data and zoom in to look at them. So averaging the data can be problematic.
I have a naive implementation using a standard GUI framework on linux which is way too slow to be practical. I'm thinking of using OpenGL instead (testing on a Radeon RX480 GPU), with orthogonal projection. I searched around and it seems VBOs to draw line strips might work, but I have no idea if this is the best solution (would give me the best frame rate).
What is the best way to send data sets consisting of millions of vertices to the GPU, assuming the data does not change, and will be redrawn each time the user interacts with it (pan/zoom/click on it)?
In modern OpenGL (versions 3/4 core profile) VBOs are the standard way to transfer geometric / non-image data to the GPU, so yes you will almost certainly end up using VBOs.
Alternatives would be uniform buffers, or texture buffer objects, but for the application you're describing I can't see any performance advantage in using them - might even be worse - and it would complicate the code.
The single biggest speedup will come from having all the data points stored on the GPU instead of being copied over each frame as a 2D GUI might be doing. So do the simplest thing that works and then worry about speed.
If you are new to OpenGL, I recommend the book "OpenGL SuperBible" 6th or 7th edition. There are many good online OpenGL guides and references, just make sure you avoid the older ones written for OpenGL 1/2.
Hope this helps.

Visualize 3D Bar Graph in C++

I have some 3D data (xyz coordinates) that I am trying to represent as a 3D bar graph. What is the best way to visualize this in C++? I would also like to display different colors based on the z value. Any information about this would be great.
Thanks in advance.
I imagine you were hoping for a turn-key solution to your problem, but, although I have seen a lot of 3D bar charts over the years, I don't have a library which I can point to and say "just use this." I once watched as researchers virtually walked around on top of a huge 3D bar chart in Second Life, discussing the depth of data exploration only immersion can offer.
The problem is that you need a dynamic view, with mouse input as a minimum. There are some libraries for 3D graphing, but those are for visualizing surfaces, which isn't really what you're after. Here's one with an ActiveX control interface for starters.
So now I'm thinking about graphical APIs, such as OpenGL and DirectX, where you could just draw the geometry yourself. But I'm not sure you know anything about graphics programming, and so getting a single triangle on screen will be a task, let alone 2*5*w*h triangles. No offense - its an actual GD ordeal.
So short of explaining how to do that in any reasonable way, now I'm wondering if I can simply sidestep the issue. You could use any number of graphing libraries to draw a matrix of charts, one for each slice in the grid. Or a 2D color heat map, where the color matches the Z value, as you suggested.
But that's not helpful, because you wanted a 3D bar chart. So maybe I can talk you out of it? While its been shown that people prefer 3D bar charts, they don't perform as well using them, compared to 2D representations. And if you want a 3D representation to be effective, you may need to employ stereo 3D or linked physical models.
I hope my ramblings have at least been amusing.
Not free, but would this fit the bill? https://www.qt.io/blog/2013/11/07/qt-data-visualization-technology-preview-and-charts-1-3-1-release
Maybe: Use R, and a C++ binding library, like Rcpp.
Or perhaps: PLplot.

How to plot Histogram and Dot diagrams and save to picture in C++

I have tested a lot of different C++ library's(SIGL, PLplot, libharu and some other randoms) for plotting but i have not found anyone that suites my need or is working properly.
My need is to create a histogram and a dot diagram using 100 000 - 1000 000 values from a 2 dimensional matrix. Save it to a picture png or jpeg format preferred.
I use Visual studio 2010 and have a Windows XP operating system.
I need to be able to use C++ and I would prefer if there was some good documentation on the library too.
Note is that I do not want to use Matlab, since that is what I am replacing.
Love
Pewdut
I definitely sympathize with not wanting to use Matlab. If it's just the non-free aspect you don't like, then Octave is a good alternative, it is a fairly complete Matlab clone escept for the gui-building facilities.
I use the GSL (very highly recommended) for creating histograms, it has library functions for doing this (1- and 2-D), and its data structures (matrix, vector) can handle at least 300,000 x 64 doubles (This is as high as I've gone on a 2GB RAM machine, naturally more RAM = more capacity, probably). It is very fast. For graphing, I use Qt, and the Qwt toolbox within it has specific functions for making histograms. The example doesn't show it but axis labels and legends are straightforward. Qt is relatively heavyweight, but superb imo.
Edit: The author of Qwt gives a list of the classes/functions that support exporting plots, here.

Plot x and y datapoints in Visual C++

I am new to plotting graphs in Visual C++. I want to use arrays as input for x- and y-axis coordinates. Please suggest some way of doing so. I have read the previous posts but I am finding gnuplot++ complex for plotting graphs.
check these out:
http://koolplot.codecutter.org/ >> its only 2d plotting but might help you as you want an easy one.
http://mathgl.sourceforge.net/mathgl_en/mathgl_en_7.html >> mathgl, if your'e familiar with opengl, this becomes easy for you to use
www.astro.caltech.edu/~tjp/pgplot >> fortan c-callable graph plotter (please bear with me as stack overflow is preventing me from posting more than two hyperlinks)
if you have a lot of data, i mean seriously large then it might be worth trying to learn opengl as you'll be direcly dealing with raster graphics.
one advantage is that you can set the viewport(how many pixels and how big) in common words you can deal with 100000*100000 points in your calculations but display it in a window of 500*500 pixels as a reduced image.
google opengl you'll go to the website, i believe edward angel's books are really good to learn and teach you only what you need.

Weather visualization from csv data files

I'm preparing for a project related to weather visualization. I have some .csv files (100 rows, 120 colums) that contain weather data measured in my country where each cell represents a point with some specific values e.g. temperature or wind speed. Those files may be perceived as sets of points of latitude and longitude that covers my whole country (in fact the values are measured every 5 miles). I'd like to transformed the data and put the values on maps to make some weather visualizations, both 2d and 3d, especially heatmaps or hightmaps. I'm wondering which technology is the best for that. I was thinking of openGL, but all the textures mapping and drawing operations seem a bit difficult to me (but maybe they're not). I'm also considering making Java applets but there are many Java graphics libraries and I don't know wich one is the best for my requirements. Maybe all those things are possible to do in XNA, whcih would be great, because I'm programming mainly in C#. I'd be glad if some more experienced programmers could recommend me an appropriate language and libraries. What would you use to make the work easy and efficient?
OpenGL is just the pencil and paper for program to draw things with. While it certainly is possible to use OpenGL for this, I strongly suggest using an off the shelf visualization tool, like Origin, Matlab Visualization, visualization modules of R, etc.
If you're more looking in the direction of a visualization programming toolkit, have a look at VTK http://www.vtk.org/
But naked OpenGL for that task: Only recommendable if you "speak OpenGL fluently".