SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

CAIRO

Name:
    CAIRO
Type:
    Output Device Command
Purpose:
    Direct graphical output to a CAIRO device.
Description:
    The following description of Cairo is taken from the Cairo web page

      Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), quartz, win32, and image buffers, as well as PDF, PostScript, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB.

      Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (for example, through the X Render Extension).

      The cairo API provides operations similar to the drawing operators of PostScript and PDF. Operations in cairo include stroking and filling cubic Bézier splines, transforming and compositing translucent images, and antialiased text rendering. All drawing operations can be transformed by any affine transformation (scale, rotation, shear, etc.).

      Cairo has been designed to let you draw anything you want in a modern 2D graphical user interface. At the same time, the cairo API has been designed to be as fun and easy to learn as possible.

    Dataplot currently supports Cairo for the Unix/Linux environment. The following Cairo devices are supported

      X11
      Postscript
      Encapsulated Postscript
      PDF (Portable Document Format)
      SVG (Scalable Vector Graphics)
      PNG (Portable Network Graphics)

    Note that with the exception of the PDF device, Dataplot has native support for these devices. One advantage of using Cairo is that the output is more consistent across the various devices. Specifically, using Cairo the output generated to the screen via X11 will be more consistent with the output generated to Postscript or PDF. This is particularly the case for hardware text. Also, the Cairo PNG device generates better output than the GD PNG device.

    The Quartz device for the Mac OS X environment and the WIN32 device for the Windows environment are currently under development.

Syntax 1:
    DEVICE 1 CAIRO X11

    This form designates device 1 (the terminal) as a X11 device. Currently, only the X11 device supports graphics to the terminal. An error message is generated if you specify one of the other supported Cairo devices for DEVICE 1.

Syntax 2:
    DEVICE <2/3> CAIRO <device> where <device> is one of POSTSCRIPT, ENCAPSULATED POSTSCRIPT, PDF, SVG, or PNG.

    DEVICE 2 and DEVICE 3 generate graphics to a file. This command is most typically used for DEVICE 2.

    X11 is not supported for DEVICE 2 or DEVICE 3.

Examples:
    DEVICE 1 CAIRO X11
    DEVICE 2 CAIRO POSTSCRIPT
    DEVICE 2 CAIRO SVG
    DEVICE 3 CAIRO PDF
    DEVICE 2 CAIRO POSTSCRIPT ENCAPSULATED
Note:
    The Cairo X11 device supports the use of the CROSS HAIR command. The Cairo X11 device can also be manually resized (the new size does not take effect until the next screen erase).
Note:
    The SVG, PNG, and ecapsulated Postscript devices expect only a single plot for each file. This can be accomplished using something like the following

      SET IPL1NA PLOT1.PNG
      DEVICE 2 CAIRO PNG
      ... Generate first plot ..
      DEVICE 2 CLOSE
      .
      SET IPL1NA PLOT2.PNG
      DEVICE 2 CAIRO PNG
      ... Generate second plot ..
      DEVICE 2 CLOSE

    The SET IPL1NA command is used to give the plot file a unique name. This basic sequence can be repeated as often as needed.

    If you try to generate multiple plots for these devices, the results will not be good (basically, the plots will be overlaid on a single page).

    The Postscript and PDF devices support multiple plots per file.

Note:
    There are several commands for supporting text with the Cairo devices.

    To specify the font for the Cairo device, enter the command

      SET CAIRO FONT <name>

    where <name> specifies the desired font. Up to 32 characters are allowed for the font name. The available fonts will vary on a specific platform, so no listing (or checking within Dataplot) is provided. The basic fonts such as Sans or Serif should be available on just about all installations. If you use a common font name such as Arial or Helvetica (or Courier for when you need a fixed space font), it should be available on most installations.

    The following additional font related commands are supported

      SET CAIRO FONT WEIGHT <NORMAL/BOLD>
      SET CAIRO FONT SLANT <NORMAL/ITALIC>

    These commands allow you to specify bold or italic text. NORMAL is the default for both of these commands.

    The following commands are used to specify characteristics for drawing lines

      SET CAIRO CAP <BUTT/ROUND/SQUARE/NONE>
      SET CAIRO JOIN <MITER/ROUND/BEVEL/NONE>

    BUTT and MITER are the defaults.

    By default, region fills are performed in hardware (i.e., by Cairo). Although this is generally faster, hardware fills can occassionally generate unintended results. To specify region fills be generated in software, use the command

      SET CAIRO HARDWARE FILL OFF
Note:
    Cairo supports a number of features that are not currently supported in Dataplot.
Default:
    Off
Synonyms:
    None
Related Commands:
    LIBPLOT = Generate graphics using the LIBPLOT library.
    GD = Generate graphics using the GD library.
    POSTSCRIPT = Generate Postscript output.
    SVG = Generate SVG output.
    X11 = Direct graphical output to an X11 device.
Applications:
    Graphics Output
Implementation Date:
    2017/11
    2023/11: Made several bug fixes
Program:
    SET IPL1NA PLOT1.PDF
    DEVICE 2 CAIRO PDF
    PLOT X**2 FOR X = 1 1 9
    DEVICE 2 CLOSE
    SET IPL1NA PLOT2.PDF
    DEVICE 2 CAIRO PDF
    PLOT X**3 FOR X = 1 1 9
    DEVICE 2 CLOSE
        
Date created: 11/07/2017
Last updated: 11/03/2023

Please email comments on this WWW page to alan.heckert@nist.gov.