Skip to content
A series of plotting widgets for Gtk2
C Shell Perl
Failed to load latest commit information.
gtk3plot Minor fixes with polarv3 Jul 14, 2014
m4 Finalised pi/donut plot Feb 8, 2014
.gitignore Merge branch 'master' into debian Aug 19, 2012
AUTHORS Restructured package and added polar plotting Feb 21, 2011 Added pointer passing functions Aug 15, 2012
ChangeLog Initial restructuring to enable compilation as a shared library Jul 6, 2012
INSTALL Polar plot added better 2d functionality with orientation property Jun 24, 2014
NEWS Restructured package and added polar plotting Feb 21, 2011
README added new reversioning script for build process Aug 20, 2012
TODO not much Aug 6, 2012 configure file fix Aug 23, 2012 Restyling package layout yet again Jul 18, 2012 Added 3d surface plot using gtkglext Dec 6, 2014


The GtkPlot Widget Family
Version 0.0.0, January 2011

GtkPlotLinear provides a widget for automated plotting of data on a linear-linear scale.
GtkPlotLogLinear, PlotLinearLog will provide similar functionality for plotting on a semilog scale.
GtkPlotLogLog will provide similar functionality for plotting on a log-log scale.
GtkPlotPolar provides similar functionality for a polar scale.
This program is my first attempt to write an object in a non-object-oriented language using object-oriented libraries and coded in as unobject-oriented a fashion as possible.
The program is coded preferentially to an in-line structure to maximise performance so my apologies to anyone that attempts to modify or understand it, but I like that my >10000 point graphs load fast.

Motivation; Technology; License
GtkPlot builds upon GtkDrawingArea. It compiles & works under gtk+2. upgrading to gtk+3 is currently under work.
This code is released under the GNU LGPL version 2 (for the gtk+2 version; the LGPL version 3 for the gtk+3 version) or (at your option) any later versions, making it suitable for pretty much anything.

Once the library is installed (see the INSTALL file) you can link to the shared library by:
1) In the source code link to the headers with, e.g.:
  #include <gtkplot-2.0/gtkplotlinear.h>
2) Compile your program by identifying gtkplot-2.0 with pkgconfig, e.g.:
  gcc -o testplotlinear testplotlinear.c `pkg-config --cflags --libs gtk+-2.0 gtk2plot-2.0`
A new plot can be made in gtk+2 using, e.g.:
  GtkWidget *plotname;
Data can be sent to the plot using GArray structures as:
  GtkPlotLinear *plot;
  GArray *xarrayname, *yarrayname, *sizes, *indices;
  gint arraysize, n=0;
  xarrayname=g_array_sized_new(FALSE, FALSE, sizeof(gdouble), arraysize);
  yarrayname=g_array_sized_new(FALSE, FALSE, sizeof(gdouble), arraysize);
  sizes=g_array_sized_new(FALSE, FALSE, sizeof(gint), arraysize);
  g_array_append_val(sizes, arraysize);
  indices=g_array_sized_new(FALSE, FALSE, sizeof(gint), arraysize);
  g_array_append_val(indices, n);
(for polar plotting these xdata and ydata arrays are replaced by rdata and thdata with similar x,y -> r,th replacements throughout)
A new interface for doing this without memory leaks is under development.
Redrawing the axes can be done by:
  gdouble xmin, xmax, ymin, ymax;
  gtk_plot_linear_update_scale(plotname, xmin, xmax, ymin, ymax);
to get strict axis bounds or:
  gdouble xmin, xmax, ymin, ymax;
  gtk_plot_linear_update_scale_pretty(plotname, xmin, xmax, ymin, ymax);
to get the best fit of six or less major tick divisions at multiples of 1, 2 or 5 times a power of 10.
Properties can be changed or accessed using:
  g_object_set(G_OBJECT(plotname), "propertyname", value, ..., NULL);
  g_object_get(G_OBJECT(plotname), "propertyname", value, ..., NULL);
respectively, where the propertyname's are explained in the _class_init function (multiple propertyname-value pairs can be entered but there must always be a NULL at the end regardless).
Publically accessable variables described in the _PlotLinear struct in the plotlinear.h header file can be accessed with:
  GtkPlotLinear *plot;
  gchar *label;
  guint mode;
  label="Frequency (Hz)";
The widget also emits a signal "moved" when the mouse moves over it which is useful for getting the corresponding location in the graph as:
  void pltmv(GtkPlotLinear *plot, gpointer data)
    gdouble x,y;
  int main(int argc, char *argv[])
    GtkPlotLinear *plot;
    g_signal_connect(plot, "moved", G_CALLBACK(pltmv), NULL);
See the example file testplotlinear.c for an example of interacting with the GtkPlotLinear widget to its full extent.

Known Bugs/Issues
GtkPlotPolar scales in an unhelpful manner and is generally very buggy (see TODO)

----------------------- THE END --------------------------------
Something went wrong with that request. Please try again.