## GwyAxis

GwyAxis — Axis with ticks and labels

## Synopsis

    #include <libgwydgets/gwydgets.h>

                        GwyAxisParams;
                        GwyAxis;
                        GwyAxisClass;
    GtkWidget*          gwy_axis_new                        (gint orientation);
    void                gwy_axis_set_logarithmic            (GwyAxis *axis,
                                                             gboolean is_logarithmic);
    void                gwy_axis_set_visible                (GwyAxis *axis,
                                                             gboolean is_visible);
    gboolean            gwy_axis_is_visible                 (GwyAxis *axis);
    gboolean            gwy_axis_is_logarithmic             (GwyAxis *axis);
    GtkPositionType     gwy_axis_get_orientation            (GwyAxis *axis);
    void                gwy_axis_set_auto                   (GwyAxis *axis,
                                                             gboolean is_auto);
    void                gwy_axis_request_range              (GwyAxis *axis,
                                                             gdouble min,
                                                             gdouble max);
    void                gwy_axis_get_range                  (GwyAxis *axis,
                                                             gdouble *min,
                                                             gdouble *max);
    void                gwy_axis_get_requested_range        (GwyAxis *axis,
                                                             gdouble *min,
                                                             gdouble *max);
    gdouble             gwy_axis_get_magnification          (GwyAxis *axis);
    const gchar*        gwy_axis_get_magnification_string   (GwyAxis *axis);
    void                gwy_axis_set_label                  (GwyAxis *axis,
                                                             const gchar *label);
    const gchar*        gwy_axis_get_label                  (GwyAxis *axis);
    void                gwy_axis_set_si_unit                (GwyAxis *axis,
                                                             GwySIUnit *unit);
    void                gwy_axis_enable_label_edit          (GwyAxis *axis,
                                                             gboolean enable);
    void                gwy_axis_draw_on_drawable           (GwyAxis *axis,
                                                             GdkDrawable *drawable,
                                                             GdkGC *gc,
                                                             gint xmin,
                                                             gint ymin,
                                                             gint width,
                                                             gint height);
    GString*            gwy_axis_export_vector              (GwyAxis *axis,
                                                             gint xmin,
                                                             gint ymin,
                                                             gint width,
                                                             gint height,
                                                             gint fontsize);
    const gdouble*      gwy_axis_get_major_ticks            (GwyAxis *axis,
                                                             guint *nticks);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GwyAxis

## Implemented Interfaces

GwyAxis implements AtkImplementorIface and GtkBuildable.

## Properties

      "auto"                     gboolean              : Read / Write
      "label"                    gchar*                : Read / Write
      "line-thickness"           gint                  : Read / Write
      "major-length"             gint                  : Read / Write
      "major-maxticks"           gint                  : Read / Write
      "major-thickness"          gint                  : Read / Write
      "minor-division"           gint                  : Read / Write
      "minor-length"             gint                  : Read / Write
      "minor-thickness"          gint                  : Read / Write
      "outer-border-width"       gint                  : Read / Write

## Signals

      "rescaled"                                       : Run First

## Description

GwyAxis is used for drawing axis. It is namely used within GwyGraph widget, but it can be also used standalone. It plots a horizontal or vertical axis with major and minor ticks, with ranges in the requested interval.

## Details

### GwyAxisParams

    typedef struct {
        gint major_length;
        gint major_thickness;
        gint major_maxticks;
        GwyAxisScaleFormat major_printmode;

        gint minor_length;
        gint minor_thickness;
        gint minor_division;          /*minor division*/

        gint line_thickness;

        PangoFontDescription *major_font;
        PangoFontDescription *label_font;
    } GwyAxisParams;

### GwyAxis

    typedef struct _GwyAxis GwyAxis;

### GwyAxisClass

    typedef struct {
        GtkWidgetClass parent_class;

        void (*rescaled)(GwyAxis *axis);

        void (*reserved1)(void);
        void (*reserved2)(void);
    } GwyAxisClass;

### gwy_axis_new ()

    GtkWidget*          gwy_axis_new                        (gint orientation);

Creates a new axis.

`orientation` : | axis orientation
Returns : | New axis as a GtkWidget.

### gwy_axis_set_logarithmic ()

    void                gwy_axis_set_logarithmic            (GwyAxis *axis,
                                                             gboolean is_logarithmic);

Sets logarithmic mode.

`axis` : | graph axis
`is_logarithmic` : | logarithmic mode

### gwy_axis_set_visible ()

    void                gwy_axis_set_visible                (GwyAxis *axis,
                                                             gboolean is_visible);

Sets the visibility of an axis.

`axis` : | An axis.
`is_visible` : | visibility

### gwy_axis_is_visible ()

    gboolean            gwy_axis_is_visible                 (GwyAxis *axis);

Determines whether axis is set to be visible.

Return: `TRUE` if `axis` is set to be visible.

`axis` : | An axis.
Returns : |

### gwy_axis_is_logarithmic ()

    gboolean            gwy_axis_is_logarithmic             (GwyAxis *axis);

Determines whether axis is set to be locarithmic.

`axis` : | An axis.
Returns : | `TRUE` if `axis` is logarithmic.

### gwy_axis_get_orientation ()

    GtkPositionType     gwy_axis_get_orientation            (GwyAxis *axis);

Gets the orientation of an axis.

`axis` : | An axis.
Returns : | The orientation.

### gwy_axis_set_auto ()

    void                gwy_axis_set_auto                   (GwyAxis *axis,
                                                             gboolean is_auto);

Enables or disables automatic axis adjustmet.

`axis` : | An axis.
`is_auto` : | `TRUE` to enable automatic tick size and distribution adjustment, `FALSE` to disable it.

### gwy_axis_request_range ()

    void                gwy_axis_request_range              (GwyAxis *axis,
                                                             gdouble min,
                                                             gdouble max);

Sets the requisition of axis boundaries.

The axis will adjust the boundaries to satisfy requisition but still have reasonable tick values and spacing. Use `gwy_axis_get_range()` to obtain the boundaries the axis actually decided to use.

`axis` : | An axis.
`min` : | Minimum requisition (min boundary value).
`max` : | Maximum requisition (max boundary value).

### gwy_axis_get_range ()

    void                gwy_axis_get_range                  (GwyAxis *axis,
                                                             gdouble *min,
                                                             gdouble *max);

Gets the actual boundaries of an axis.

`axis` : | An axis.
`min` : | Location to store actual axis minimum, or `NULL`.
`max` : | Location to store actual axis maximum, or `NULL`.

### gwy_axis_get_requested_range ()

    void                gwy_axis_get_requested_range        (GwyAxis *axis,
                                                             gdouble *min,
                                                             gdouble *max);

Gets the requested boundaries of an axis.

`axis` : | An axis.
`min` : | Location to store requested axis minimum, or `NULL`.
`max` : | Location to store requested axis maximum, or `NULL`.

### gwy_axis_get_magnification ()

    gdouble             gwy_axis_get_magnification          (GwyAxis *axis);

`axis` : | Axis widget
Returns : | Magnification value of the axis

### gwy_axis_get_magnification_string ()

    const gchar*        gwy_axis_get_magnification_string   (GwyAxis *axis);

Gets the magnification string of an axis.

`axis` : | An axis.
Returns : | Magnification string of the axis, owned by the axis.

### gwy_axis_set_label ()

    void                gwy_axis_set_label                  (GwyAxis *axis,
                                                             const gchar *label);

Sets the label text of an axis.

`axis` : | An axis.
`label` : | The new label text (it can be `NULL` for an empty label).

### gwy_axis_get_label ()

    const gchar*        gwy_axis_get_label                  (GwyAxis *axis);

Gets the label of an axis.

`axis` : | An axis.
Returns : | Axis label as a string owned by `axis`.

### gwy_axis_set_si_unit ()

    void                gwy_axis_set_si_unit                (GwyAxis *axis,
                                                             GwySIUnit *unit);

Sets the axis unit. This will be added automatically to the label. `unit` is duplicated.

`axis` : | An axis.
`unit` : | axis unit

### gwy_axis_enable_label_edit ()

    void                gwy_axis_enable_label_edit          (GwyAxis *axis,
                                                             gboolean enable);

Enables/disables user to change axis label by clicking on axis widget.

`axis` : | Axis widget
`enable` : | enable/disable user to change axis label

### gwy_axis_draw_on_drawable ()

    void                gwy_axis_draw_on_drawable           (GwyAxis *axis,
                                                             GdkDrawable *drawable,
                                                             GdkGC *gc,
                                                             gint xmin,
                                                             gint ymin,
                                                             gint width,
                                                             gint height);

Draws the x and y-axis on a drawable

`axis` : | An axis.
`drawable` : | Drawable to draw on.
`gc` : | Graphics context. It is modified by this function unpredictably.
`xmin` : | The minimum x-axis value.
`ymin` : | The minimum y-axis value.
`width` : | The width of the x-axis.
`height` : | The height of the y-axis.

### gwy_axis_export_vector ()

    GString*            gwy_axis_export_vector              (GwyAxis *axis,
                                                             gint xmin,
                                                             gint ymin,
                                                             gint width,
                                                             gint height,
                                                             gint fontsize);

`axis` : | An axis.
`xmin` : |
`ymin` : |
`width` : | width of the x-axis
`height` : | hieght of the y-axis
`fontsize` : |
Returns : |

### gwy_axis_get_major_ticks ()

    const gdouble*      gwy_axis_get_major_ticks            (GwyAxis *axis,
                                                             guint *nticks);

Gets the positions of major ticks of an axis.

`axis` : | An axis.
`nticks` : | Location to store the number of returned ticks.
Returns : | The positions of axis major ticks (as real values, not pixels). The returned array is owned by the axis.

## Property Details

### The `"auto"` property

      "auto"                     gboolean              : Read / Write

Autoscale ticks with changing content.

Default value: TRUE

### The `"label"` property

      "label"                    gchar*                : Read / Write

Axis label (without units).

Default value: ""

### The `"line-thickness"` property

      "line-thickness"           gint                  : Read / Write

Axis main line thickness.

Allowed values: [0,20]

Default value: 5

### The `"major-length"` property

      "major-length"             gint                  : Read / Write

Major ticks length.

Allowed values: [0,20]

Default value: 5

### The `"major-maxticks"` property

      "major-maxticks"           gint                  : Read / Write

Major ticks maximum number.

Allowed values: [0,50]

Default value: 5

### The `"major-thickness"` property

      "major-thickness"          gint                  : Read / Write

Major ticks thickness.

Allowed values: [0,20]

Default value: 5

### The `"minor-division"` property

      "minor-division"           gint                  : Read / Write

Minor ticks division.

Allowed values: [0,20]

Default value: 5

### The `"minor-length"` property

      "minor-length"             gint                  : Read / Write

Minor ticks length.

Allowed values: [0,20]

Default value: 5

### The `"minor-thickness"` property

      "minor-thickness"          gint                  : Read / Write

Minor ticks thickness.

Allowed values: [0,20]

Default value: 5

### The `"outer-border-width"` property

      "outer-border-width"       gint                  : Read / Write

The extra amount of space left on the outer side of an axis. This space is also retained when axis is set non-visible.

Allowed values: >= 0

Default value: 5

## Signal Details

### The `"rescaled"` signal

    void                user_function                      (GwyAxis *gwyaxis,
                                                            gpointer user_data)      : Run First

`gwyaxis` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

## See Also

GwyColorAxis -- Axis with a false color scale, GwyRuler -- Horizontal and vertical rulers