plotSetFonts

Purpose

Sets the fonts for one or more elements of a graph.

Format

plotSetFonts(&myPlot, location, font_name [, font_size, font_color]])
Parameters:
  • &myPlot (struct pointer) – A plotControl structure pointer.

  • location (Nx1 string array) –

    Optional argument, which attributes the interpreter change applies to.

    Valid options:

    ”all”

    ”legend”

    ”legend_title”

    ”title”

    ”axes”

    ”xaxis”

    ”xtop”

    ”xbottom”

    ”yaxis”

    ”yleft”

    ”yright”

    ”zaxis”

    ”ticks” (numbers or tick labels)

    ”xticks”

    ”xtopticks”

    ”xbottomticks”

    ”yticks”

    ”yleftticks”

    ”yrightticks”

    ”zticks”

  • font (string) – Optional argument, font or font family name. If this is an empty string, the font family setting will be left unchanged.

  • fontSize (scalar) – Optional argument, font size in points.

  • fontColor (string) – Optional argument, named color or RGB value.

Examples

Set the font family and size for all text

This example will first set the font family and size for all text. It will then add a y-axis label using this font and finally add a title which uses the font family that was set, but alters the size.

new;

// Declare plotControl structure
struct plotControl myPlot;

// Initialize plotControl structure
myPlot = plotGetDefaults("hist");

// Set all text in the font to use "times" 12 pt font
plotSetFonts(&myPlot, "all", "times", 12);

// Add y-axis label using font specified above
plotSetYLabel(&myPlot, "Count");

// Since we pass in an empty string "" for
// the title font, it will be left alone
plotSetTitle(&myPlot, "Histgram of Random Normal Data", "", 14);

// Create data
x = rndn(1e5, 1);

// Plot a histogram of the x data spread over 20 bins
plotHist(myPlot, x, 20);

Set the font family, size and color for the x-axis and legend

// Declare plotControl structure
// and fill we default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("scatter");

plotSetFonts(&myPlot, "xaxis legend", "arial", 14, "dimgray");

// Set the x-axis label
plotSetXLabel(&myPlot, "X variable");

// Plot some random normal data
plotScatter(myPlot, rndn(100, 1), rndn(100,1);

Note

This function sets an attribute in a plotControl structure. It does not affect an existing graph, or a new graph drawn using the default settings that are accessible from the Tools > Preferences > Graphics menu.