How to use graph with gtk+3.0

Hi there,
I am using GTK+3 for application development in a embedded microprocessor (Toradex Colibri iMX6DL) and thanks for the user-friendly application development with GTK. I am using Eclipse neon 3 as IDE to debug and i almost completed the application. But the main part of my application is to plot a graph with the set of data from two sensors. Now, I am struck in the graph part and i tried cairo but plotted graphs without scale. So can you suggest me how to plot graph with scaling options and also the graph should be zoom-able in gtk3. Thank you for your time

When that is the main part, why not care for that from the beginning? I guess that is your homework from your teacher, and you are looking for ready made plot widget? In this case I can not really help, sorry. I think I have seen some basic GTK plot like apps 10 years ago, but none really comparable with tools like gnuplot. I assume you know how to use cairo scale() and transform() – I did a zooming example in And once I investigated axis label generation in But no tool or widget from me yet. The only recent attempt I am aware of is

but that may be too large for embedded. But when your data are sane and well bounded some cairo scale() and transforn may be enough to you.

Thank you for your time but i am new to gtk and cairo so i will try to do it mean while i am using GTK+ not gtkmm.

There is also but that doesn’t seem very active.

Hi Nishanth,

There are a number of options for graphing with GTK. Here are a couple. Gnuplot and Plplot will work with GTK. I haven’t tried Plplot but there is a simple setup for gnuplot at

If you want to do the graphing yourself with cairo there is a 3d histogram chart at

that might give you some ideas. It can draw 2d and 3d along with outputting to .svg and .pdf. There is a 3d pie chart in that folder also. For 3d meshes take a look at cairo3d_combo_UI2.c in the cairo3d folder. All of these scale. The gradient meshes get rasterized but the other drawings output to .svg and .pdf.

If you back up to the Misc folder in the path there is a MultiGraph folder with a multigraph widget if you are interested in putting together a graph widget for you application.

Have fun graphing.


hi @jensgeorg… Thanks for your time mate. Actually i tried slope and was successful with the examples provided but the problem is
1.I want to add the graph in a box which i create in my glade file, when i did that, the problem is slope graph returns a graph as toplevel widget hence i cant add that in my glade widget programmatically.
2.My application is based on checking graphs and their intersections. That is one graph is plotted by the data from sensors and the another graph will be drawn by the user on the graph area so once when the user touches a area in graph, the graph need to return me the value so i can draw on that area and create a plot and this plot will be common and the sensor data graph will be varying after intervals. That is the user drawn graph acts as reference and i need to check for intersection of consecutive graph

So is it possible in slope,i tried but i cant get that.
Thank you

hi @cecashon
Will check these graphs and thanks for your time

The slope_view is a GtkWidget that you can just add, see demos/widgets.c.

I think you could add the user input as a new xy series to the graph, but you would probably check for yourself if the two series match up

hi @jensgeorg I tried slope and quite successful with my requirements. Thanks for your time

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.