15

I want to plot some graphs with (x,y) points which is generated from a C++ programme. I can successfully plot these data from gnuplot command from a terminal.

But I want to plot the same thing from a C++ programme, is this thing possible in ubuntu 16.04 lts ?

6
  • Maybe you can have a look at the GnuPlotScripting C++17 lib. Commented Mar 8, 2020 at 18:27
  • @PicaudVincent, I had a look at the library and it may fit what I am trying to do. I wonder if it can do candlestick charts, as well as embedding the plot into a window created by wxWidgets? Commented Dec 24, 2022 at 15:49
  • Also you may wanna contact gnuplot to add that library to their list of interfaces here. Commented Dec 24, 2022 at 16:20
  • @CaTx thanks to free_form you have access to all gnuplot commands, by example script.free_form("plot {} using 1:3:2:6:5 with candlesticks", data); should work. Concerning wxWidgets nothing is present in my package to do that, sorry Commented Dec 25, 2022 at 8:02
  • @CaTx Thanks for the suggestion. I had made the request in the past, but there was no update. Commented Dec 25, 2022 at 8:03

3 Answers 3

16

Sure, just install gnuplot using standard package command:

sudo apt-get update
sudo apt-get install gnuplot

After that you just need to integrate gnuplot iostream header which is an interface for gnuplot from C++:

#include "gnuplot-iostream.h"

This header is not included when you install gnuplot but can be found here. Here you have an example link of iostream for reference: iostream example code C++

Sign up to request clarification or add additional context in comments.

Comments

8

I am adding an answer since I cannot comment. As hackela said you can install gnuplot, then you can install gnuplot-iostream from aptitude instead of dowloading manually the header file, with this command:

sudo apt-get install libgnuplot-iostream-dev

Comments

5

Another option: C++ lib matplotplusplus is actually sending drawing commands to GnuPlot. It provides an API similar to python matplotlib. It is available in C++ package manager vcpkg.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.