Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A series of plotting widgets for Gtk2
C Shell
branch: debian
Failed to load latest commit information.
SPECS Added 3d surface plot using gtkglext
debian A few fixes discovered while packaging
gtk2plot Fixed opengl left handed issue
gtk3plot Minor fixes with polarv3
m4 Finalised pi/donut plot
AUTHORS Added pointer passing functions Added pointer passing functions
ChangeLog Initial restructuring to enable compilation as a shared library
INSTALL added new reversioning script for build process Polar plot added better 2d functionality with orientation property
NEWS Restructured package and added polar plotting
README added new reversioning script for build process
TODO not much configure file fix Restyling package layout yet again Added 3d surface plot using gtkglext


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.