See the documentation of the add method, especially what
alreadysorted does, and what happens when you modify the keys of data points after having them added to the graph:
QCPDataContainer<DataType> general documentation
especially this part:
The data can be accessed with the provided const iterators (constBegin, constEnd). If it is necessary to alter existing data in-place, the non-const iterators can be used (begin, end). Changing data members that are not the sort key (for most data types called key) is safe from the container's perspective.
Great care must be taken however if the sort key is modified through the non-const iterators. For performance reasons, the iterators don't automatically cause a re-sorting upon their manipulation. It is thus the responsibility of the user to leave the container in a sorted state when finished with the data manipulation, before calling any other methods on the container. A complete re-sort (e.g. after finishing all sort key manipulation) can be done by calling sort. Failing to do so can not be detected by the container efficiently and will cause both rendering artifacts and potential data loss.
Your new data points are all (0, 0) when you add them to the graph. If you modify the points (especially the keys) after that, you would need to manually sort them correctly or call a whole sorting run. This is not a good way to do it. It's better to set the keys and values of the new points in
my_new_data and then add them to the graph.
Also in this case, If you set
alreadysorted to true, you must be 100% sure that the keys are sorted ascending. Since you're only adding 100 points I recommend just leaving it off for safety (you might not have full control over what comes via USB). At 100 points you won't feel any speed benefit, and doing the check on an already sorted vector is very fast anyhow.