I wrote a program similar to this using Qt. Qt is wonderful once you get it set up, but it may take a bit of effort if you've never used it (as will OpenGL, DirectX, etc..).
You can create a QImage and set it to whatever background color you want, then run your program through the width of the image pixel by pixel calling your function to get the y value. Roughly:
for (int i = 0; i < imageWidth; i++) {
image->setPixel(i, yourFunction(i), lineColor);
}
Once you've created your QImage, you can attach it to a QLabel using setPixmap(). Once you've attached it you can then display the image in a layout.