Previous: set_style_line, Up: style


2.19.57.6 plotting styles

The commands `set style data` and `set style function` change the default plotting style for subsequent `plot` and `splot` commands.

The types used for all line and point styles (i.e., solid, dash-dot, color, etc. for lines; circles, squares, crosses, etc. for points) will be either those specified on the `plot` or `splot` command or will be chosen sequentially from the types available to the terminal in use. Use the command test to see what is available.

None of the styles requiring more than two columns of information (e.g., errorbars or errorlines) can be used with `splot`s or function `plot`s. Neither `boxes`, `filledcurves` nor any of the `steps` styles can be used with `splot`s. If an inappropriate style is specified, it will be changed to `points`.

For 2-d data with more than two columns, `gnuplot` is picky about the allowed errorbars and errorlines styles. The using option on the `plot` command can be used to set up the correct columns for the style you want. (In this discussion, "column" will be used to refer both to a column in the data file and an entry in the using list.)

For three columns, only `xerrorbars`, `yerrorbars` (or errorbars), `xerrorlines`, `yerrorlines` (or errorlines), `boxes` and `boxerrorbars` are allowed. If another plot style is used, the style will be changed to `yerrorbars`. The `boxerrorbars` style will calculate the boxwidth automatically.

For four columns, only `xerrorbars`, `yerrorbars` (or errorbars), `xyerrorbars`, `xerrorlines`, `yerrorlines` (or errorlines), `xyerrorlines`, `boxxyerrorbars`, and `boxerrorbars` are allowed. An illegal style will be changed to `yerrorbars`.

Five-column data allow only the `boxerrorbars`, `financebars`, and `candlesticks` styles. An illegal style will be changed to `boxerrorbars` before plotting.

Six- and seven-column data only allow the `xyerrorbars`, `xyerrorlines`, and `boxxyerrorbars` styles. Illegal styles will be changed to `xyerrorbars` before plotting.

For more information about error bars with and without lines, please see errorlines and errorbars.

— BOXERRORBARS —

The `boxerrorbars` style is only relevant to 2-d data plotting. It is a combination of the `boxes` and `yerrorbars` styles. The boxwidth will come from the fourth column if the y errors are in the form of "ydelta" and the boxwidth was not previously set equal to -2.0 (`set boxwidth -2.0`) or from the fifth column if the y errors are in the form of "ylow yhigh". The special case `boxwidth = -2.0` is for four-column data with y errors in the form "ylow yhigh". In this case the boxwidth will be calculated so that each box touches the adjacent boxes. The width will also be calculated in cases where three-column data are used.

The box height is determined from the y error in the same way as it is for the `yerrorbars` style—either from y-ydelta to y+ydelta or from ylow to yhigh, depending on how many data columns are provided. See also errorbar demo.

— BOXES —

The `boxes` style is only relevant to 2-d plotting. It draws a box centered about the given x coordinate from the x axis (not the graph border) to the given y coordinate. The width of the box is obtained in one of three ways. If it is a data plot and the data file has a third column, this will be used to set the width of the box. If not, if a width has been set using the boxwidth command, this will be used. If neither of these is available, the width of each box will be calculated automatically so that it touches the adjacent boxes.

The interior of the boxes is drawn according to the current fillstyle. See `set style fill` for details. Alternatively a new fillstyle may be specified in the plot command.

For fillstyle `empty` the box is filled with the background color.

For fillstyle `solid` the box is filled with a solid rectangle of the current drawing color. There is an optional parameter <density> that controls the fill density; it runs from 0 (background color) to 1 (current drawing color).

For fillstyle `pattern` the box is filled in the current drawing color with a pattern, if supported by the terminal driver.

Examples:

To plot a data file with solid filled boxes with a small vertical space separating them (bargraph):

           set boxwidth 0.9 relative
           set style fill solid 1.0
           plot 'file.dat' with boxes
     

To plot a sine and a cosine curve in pattern-filled boxes style:

           set style fill pattern
           plot sin(x) with boxes, cos(x) with boxes
     

The sin plot will use pattern 0; the cos plot will use pattern 1. Any additional plots would cycle through the patterns supported by the terminal driver.

To specify explicit fillstyles for each dataset:

          plot 'file1' with boxes fs solid 0.25, \
               'file2' with boxes fs solid 0.50, \
               'file3' with boxes fs solid 0.75, \
               'file4' with boxes fill pattern 1, \
               'file5' with boxes fill empty
     

Currently only the following terminal drivers support fillstyles other than `empty`: x11, windows, pm, postscript, fig, pbm, png, gif, hpdj, hppj, hpljii, hp500c, jpeg, nec_cp6, epson_180dpi, epson_60dpi, epson_lx800, okidata, starc and tandy_60dpi. The BeOS driver (`be`) is untested.

— FILLEDCURVES —

The `filledcurves` style is only relevant to 2-d plotting. It draws either the current curve closed and filled, or the region between the current curve and a given axis, horizontal or vertical line, or a point, filled with the current drawing color.

Syntax:

         set style [data | function] filledcurves [option]
         plot ... with filledcurves [option]
     

where the option can be

         [closed | {x1 | x2 | y1 | y2}[=<a>] | xy=<x>,<y>]
     

The area is filled between the current curve and

         filledcurves closed   ... just filled closed curve,
         filledcurves x1       ... x1 axis,
         filledcurves x2       ... x2 axis, etc for y1 and y2 axes,
         filledcurves y1=0     ... line y=0 (at y1 axis) ie parallel to x1 axis,
         filledcurves y2=42    ... line y=42 (at y2 axis) ie parallel to x2, etc,
         filledcurves xy=10,20 ... point 10,20 of x1,y1 axes (arc-like shape).
     

Note: filling is supported on filled-polygon capable terminals, see help of pm3d for their list.

Zoom of a filled curve drawn from a datafile may produce empty or incorrect area because gnuplot is clipping points and lines, and not areas.

If the values of <a>, <x>, <y> are out of the drawing boundary, then they are moved to the graph boundary. Then the actually filled area in the case of option xy=<x>,<y> will depend on xrange and yrange.

— BOXXYERRORBARS —

The `boxxyerrorbars` style is only relevant to 2-d data plotting. It is a combination of the `boxes` and `xyerrorbars` styles.

The box width and height are determined from the x and y errors in the same way as they are for the `xyerrorbars` style—either from xlow to xhigh and from ylow to yhigh, or from x-xdelta to x+xdelta and from y-ydelta to y+ydelta , depending on how many data columns are provided.

If filled-box support is present, then the interior of the boxes is drawn according to the current fillstyle. See `set style fill` and `boxes` for details. Alternatively a new fillstyle may be specified in the plot command.

— CANDLESTICKS —

The `candlesticks` style can be used for 2-d data plotting of financial data or for generating box-and-whisker plots of statistical data. Five columns of data are required; in order, these should be the x coordinate (most likely a date) and the opening, low, high, and closing prices. The symbol is a rectangular box, centered horizontally at the x coordinate and limited vertically by the opening and closing prices. A vertical line segment at the x coordinate extends up from the top of the rectangle to the high price and another down to the low. The vertical line will be unchanged if the low and high prices are interchanged.

The width of the rectangle can be controlled by the boxwidth command. For backwards compatibility with earlier gnuplot versions, when the boxwidth parameter has not been set then the width of the candlestick rectangle is controlled by `set bars <width>`.

By default the rectangle is empty if (open > close), and filled with three vertical bars if (close > open). If filled-boxes support is present, then the rectangle is colored according to `set style fill <fillstyle>`. See bars and `financebars`. See also finance demos.

Note: To place additional symbols, such as the median value, on a box-and-whisker plot requires additional plot commands as in this example:

       # Data columns: X Min 1stQuartile Median 3rdQuartile Max
       set bars 4.0
       set style fill empty
       plot 'stat.dat' using 1:3:2:6:5 with candlesticks title 'Quartiles', \
            ''         using 1:4:4:4:4 with candlesticks lt -1 notitle
     
      See boxwidth, bars and `set style fill`.
     

— DOTS —

The `dots` style plots a tiny dot at each point; this is useful for scatter plots with many points.

— FINANCEBARS —

The `financebars` style is only relevant for 2-d data plotting of financial data. Five columns of data are required; in order, these should be the x coordinate (most likely a date) and the opening, low, high, and closing prices. The symbol is a vertical line segment, located horizontally at the x coordinate and limited vertically by the high and low prices. A horizontal tic on the left marks the opening price and one on the right marks the closing price. The length of these tics may be changed by bars. The symbol will be unchanged if the high and low prices are interchanged. See bars and `candlesticks`, and also the finance demo.

— FSTEPS —

The `fsteps` style is only relevant to 2-d plotting. It connects consecutive points with two line segments: the first from (x1,y1) to (x1,y2) and the second from (x1,y2) to (x2,y2). See also steps demo.

— HISTEPS —

The `histeps` style is only relevant to 2-d plotting. It is intended for plotting histograms. Y-values are assumed to be centered at the x-values; the point at x1 is represented as a horizontal line from ((x0+x1)/2,y1) to ((x1+x2)/2,y1). The lines representing the end points are extended so that the step is centered on at x. Adjacent points are connected by a vertical line at their average x, that is, from ((x1+x2)/2,y1) to ((x1+x2)/2,y2).

If autoscale is in effect, it selects the xrange from the data rather than the steps, so the end points will appear only half as wide as the others. See also steps demo.

`histeps` is only a plotting style; `gnuplot` does not have the ability to create bins and determine their population from some data set.

— IMPULSES —

The `impulses` style displays a vertical line from the x axis (not the graph border), or from the grid base for `splot`, to each point.

— LINES —

The `lines` style connects adjacent points with straight line segments. See also `linetype`, `linewidth`, and `linestyle`.

— LINESPOINTS —

The `linespoints` style does both `lines` and `points`, that is, it draws a small symbol at each point and then connects adjacent points with straight line segments. The command pointsize may be used to change the size of the points. See pointsize for its usage.

`linespoints` may be abbreviated `lp`.

— POINTS —

The `points` style displays a small symbol at each point. The command pointsize may be used to change the size of the points. See pointsize for its usage.

— STEPS —

The `steps` style is only relevant to 2-d plotting. It connects consecutive points with two line segments: the first from (x1,y1) to (x2,y1) and the second from (x2,y1) to (x2,y2). See also steps demo.

— VECTORS —

The `vectors` style draws a vector from (x,y) to (x+xdelta,y+ydelta). Thus it requires four columns of data. It also draws a small arrowhead at the end of the vector.

Example:

           plot 'file.dat' using 1:2:3:4 with vectors head filled lt 2
     

`set clip one` and `set clip two` affect drawing vectors. Please see clip and `arrowstyle`.

— XERRORBARS —

The `xerrorbars` style is only relevant to 2-d data plots. `xerrorbars` is like `dots`, except that a horizontal error bar is also drawn. At each point (x,y), a line is drawn from (xlow,y) to (xhigh,y) or from (x-xdelta,y) to (x+xdelta,y), depending on how many data columns are provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details).

— XYERRORBARS —

The `xyerrorbars` style is only relevant to 2-d data plots. `xyerrorbars` is like `dots`, except that horizontal and vertical error bars are also drawn. At each point (x,y), lines are drawn from (x,y-ydelta) to (x,y+ydelta) and from (x-xdelta,y) to (x+xdelta,y) or from (x,ylow) to (x,yhigh) and from (xlow,y) to (xhigh,y), depending upon the number of data columns provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details).

If data are provided in an unsupported mixed form, the using filter on the `plot` command should be used to set up the appropriate form. For example, if the data are of the form (x,y,xdelta,ylow,yhigh), then you can use

           plot 'data' using 1:2:($1-$3):($1+$3):4:5 with xyerrorbars
     

— YERRORBARS —

The `yerrorbars` (or errorbars) style is only relevant to 2-d data plots. `yerrorbars` is like `points`, except that a vertical error bar is also drawn. At each point (x,y), a line is drawn from (x,y-ydelta) to (x,y+ydelta) or from (x,ylow) to (x,yhigh), depending on how many data columns are provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details). See also errorbar demo.

— XERRORLINES —

The `xerrorlines` style is only relevant to 2-d data plots. `xerrorlines` is like `linespoints`, except that a horizontal error line is also drawn. At each point (x,y), a line is drawn from (xlow,y) to (xhigh,y) or from (x-xdelta,y) to (x+xdelta,y), depending on how many data columns are provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details).

— XYERRORLINES —

The `xyerrorlines` style is only relevant to 2-d data plots. `xyerrorlines` is like `linespoints`, except that horizontal and vertical error bars are also drawn. At each point (x,y), lines are drawn from (x,y-ydelta) to (x,y+ydelta) and from (x-xdelta,y) to (x+xdelta,y) or from (x,ylow) to (x,yhigh) and from (xlow,y) to (xhigh,y), depending upon the number of data columns provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details).

If data are provided in an unsupported mixed form, the using filter on the `plot` command should be used to set up the appropriate form. For example, if the data are of the form (x,y,xdelta,ylow,yhigh), then you can use

           plot 'data' using 1:2:($1-$3):($1+$3):4:5 with xyerrorlines
     

— YERRORLINES —

The `yerrorlines` (or errorlines) style is only relevant to 2-d data plots. `yerrorlines` is like `linespoints`, except that a vertical error line is also drawn. At each point (x,y), a line is drawn from (x,y-ydelta) to (x,y+ydelta) or from (x,ylow) to (x,yhigh), depending on how many data columns are provided. A tic mark is placed at the ends of the error bar (unless bars is used—see bars for details). See also errorbar demo.