Link against libsciplot and include the header:
The pkg-config name is sciplot (once installed); for an uninstalled build, pass the compiler and linker flags from pkg-config gtk4 cairo pangocairo.
Create the widget and add it to your GTK4 widget hierarchy in the normal way:
Data is plotted in groups called lists. Each list consists of a set
of coordinates connected by a line, sharing a point style, point colour, line
style, line colour, and legend label. Data is added via convenience functions
only.
The SCIPLOT_SKIP_VAL marker causes a break in the line, producing disjoint segments.
Changes are not visible until SciPlotUpdate() is called.
Properties are set and retrieved with explicit functions of the form sciplot_widget_set_name() and sciplot_widget_get_name(). The defaults match the original Xt resource defaults.
| Set function | Get function | Type | Default |
|---|---|---|---|
| sciplot_widget_set_axis_font | — | int (font flags) | XtFONT_TIMES|10 |
| sciplot_widget_set_chart_type | — | int | XtCARTESIAN |
| sciplot_widget_set_degrees | — | gboolean | TRUE |
| sciplot_widget_set_draw_major | sciplot_widget_get_draw_major | gboolean | TRUE |
| sciplot_widget_set_draw_major_tics | — | gboolean | TRUE |
| sciplot_widget_set_draw_minor | sciplot_widget_get_draw_minor | gboolean | TRUE |
| sciplot_widget_set_draw_minor_tics | — | gboolean | TRUE |
| sciplot_widget_set_label_font | — | int (font flags) | XtFONT_TIMES|18 |
| sciplot_widget_set_legend_through_plot | — | gboolean | FALSE |
| sciplot_widget_set_margin | — | int (pixels) | 5 |
| sciplot_widget_set_monochrome | — | gboolean | FALSE |
| sciplot_widget_set_plot_title | sciplot_widget_get_plot_title | const char * | "Plot" |
| sciplot_widget_set_show_legend | sciplot_widget_get_show_legend | gboolean | TRUE |
| sciplot_widget_set_show_title | sciplot_widget_get_show_title | gboolean | TRUE |
| sciplot_widget_set_show_xlabel | sciplot_widget_get_show_xlabel | gboolean | TRUE |
| sciplot_widget_set_show_ylabel | sciplot_widget_get_show_ylabel | gboolean | TRUE |
| sciplot_widget_set_title_font | — | int (font flags) | XtFONT_HELVETICA|24 |
| sciplot_widget_set_title_margin | — | int (pixels) | 16 |
| sciplot_widget_set_xaxis_numbers | sciplot_widget_get_xaxis_numbers | gboolean | TRUE |
| sciplot_widget_set_xlabel | sciplot_widget_get_xlabel | const char * | "X Axis" |
| sciplot_widget_set_xlog | sciplot_widget_get_xlog | gboolean | FALSE |
| sciplot_widget_set_xorigin | sciplot_widget_get_xorigin | gboolean | FALSE |
| sciplot_widget_set_yaxis_numbers | sciplot_widget_get_yaxis_numbers | gboolean | TRUE |
| sciplot_widget_set_ylabel | sciplot_widget_get_ylabel | const char * | "Y Axis" |
| sciplot_widget_set_ylog | sciplot_widget_get_ylog | gboolean | FALSE |
| sciplot_widget_set_y_numbers_horizontal | — | gboolean | TRUE |
| sciplot_widget_set_yorigin | sciplot_widget_get_yorigin | gboolean | FALSE |
Colors are referenced by integer IDs returned from the allocation functions. Two colours are pre-allocated at widget creation:
| ID | Colour |
|---|---|
| 0 | white (background) |
| 1 | black (foreground) |
User colours start at index 2. Color names follow the CSS/GDK convention accepted by gdk_rgba_parse() (e.g., "red", "#ff8000", "rgb(0,128,255)").
Fonts are specified by logically OR-ing an XtFONT_* family constant with optional style flags and a point size:
| Constant | Pango family |
|---|---|
| XtFONT_TIMES | Times New Roman |
| XtFONT_COURIER | Courier New |
| XtFONT_HELVETICA | Helvetica |
| XtFONT_LUCIDA | Lucida Bright |
| XtFONT_LUCIDASANS | Lucida Sans |
| XtFONT_NCSCHOOLBOOK | Century Schoolbook L |
| Style constant | Effect |
|---|---|
| XtFONT_BOLD | Bold weight |
| XtFONT_ITALIC | Italic style |
| XtFONT_BOLD_ITALIC | Bold and italic (= XtFONT_BOLD|XtFONT_ITALIC) |
Examples:
XtFONT_TIMES|XtFONT_BOLD|12
XtFONT_COURIER|10
XtFONT_LUCIDA|XtFONT_BOLD_ITALIC|16
If a requested font family is not installed, Pango will substitute the nearest available alternative.
| Constant | Description |
|---|---|
| XtMARKER_NONE | no marker |
| XtMARKER_CIRCLE | open circle |
| XtMARKER_SQUARE | open square |
| XtMARKER_UTRIANGLE | triangle pointing up |
| XtMARKER_DTRIANGLE | triangle pointing down |
| XtMARKER_LTRIANGLE | triangle pointing left |
| XtMARKER_RTRIANGLE | triangle pointing right |
| XtMARKER_DIAMOND | diamond |
| XtMARKER_HOURGLASS | hourglass |
| XtMARKER_BOWTIE | bowtie |
| XtMARKER_FCIRCLE | filled circle |
| XtMARKER_FSQUARE | filled square |
| XtMARKER_FUTRIANGLE | filled triangle up |
| XtMARKER_FDTRIANGLE | filled triangle down |
| XtMARKER_FLTRIANGLE | filled triangle left |
| XtMARKER_FRTRIANGLE | filled triangle right |
| XtMARKER_FDIAMOND | filled diamond |
| XtMARKER_FHOURGLASS | filled hourglass |
| XtMARKER_FBOWTIE | filled bowtie |
| XtMARKER_DOT | small filled dot |
| Constant | Description |
|---|---|
| XtLINE_NONE | no line (points only) |
| XtLINE_SOLID | solid line |
| XtLINE_DOTTED | dotted line |
| XtLINE_WIDEDOT | widely-spaced dotted line |
EPS output is generated via Cairo's PS surface and faithfully reproduces the on-screen plot including all colours. Both SciPlotPSCreate and SciPlotPSCreateColor produce colour output (the distinction is retained for API compatibility).
All functions take GtkWidget *w as their first argument (the SciPlot widget instance). Changes to data or styles are not visible until SciPlotUpdate() is called.
All creation functions return an integer list ID used by subsequent calls. Pass num=0 and NULL arrays to create an empty list and populate it incrementally with SciPlotListAddFloat etc.