Re: [gtkextra] labels in the X axis
Tobias Rapp <[email protected]>
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
hi!
> I'm using GtkPlot and Gtkextra, and i don't know how
> i can put labels like (Monday, thuesday, ...) in X
> axis, i sow iin the examples of Scigraphica that it
> coull be posible.
have a look at testgtkplot.c for these lines:
/* lines 217-226 */
my_tick_label(GtkPlotAxis *axis, gdouble *tick_value, gchar *label,
gpointer data)
{
gboolean return_value = FALSE;
if(*tick_value == 0.0){
g_snprintf(label, 100, "custom label at 0.0");
return_value = TRUE;
}
return return_value;
}
/* lines 246-249 */
gtk_plot_axis_use_custom_tick_labels(GTK_PLOT(active_plot),
GTK_PLOT_AXIS_RIGHT, TRUE);
axis = gtk_plot_get_axis(GTK_PLOT(active_plot), GTK_PLOT_AXIS_RIGHT);
gtk_signal_connect(GTK_OBJECT(axis), "tick_label",
GTK_SIGNAL_FUNC(my_tick_label), NULL);
if you want to use your custom x-labels you just have to use the
GTK_PLOT_AXIS_BOTTOM instead and use your custom tick_label handler. in
this handler you could read the numerical x-value through *tick_value,
convert it to a string representing a day and save the string in 'label' as
shown above.
hint: if you use dates as x-values it is perhaps most useful to use the
time_t (an integer) as the numerical representation and the strftime() or a
simillar function to convert it into a string representation.
greetings,
tobias
--
tobias rapp -- homepage: http://yahuxo.de
stimm mit gegen die schwerkraft: http://yahuxo.de/guestbook.html
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en