Documentation ¶
Overview ¶
Package plt contains functions for plotting, drawing in 2D or 3D, and generationg PNG and EPS files
Index ¶
- Variables
- func Annotate(x, y float64, txt string, args *A)
- func AnnotateXlabels(x float64, txt string, args *A)
- func Arc(xc, yc, r, minAlpha, maxAlpha float64, args *A)
- func Arrow(xi, yi, xf, yf float64, args *A)
- func AutoScale(P [][]float64)
- func AxDist(dist float64)
- func AxHline(y float64, args *A)
- func AxVline(x float64, args *A)
- func AxisLims(lims []float64)
- func AxisOff()
- func AxisRange(xmin, xmax, ymin, ymax float64)
- func AxisRange3d(xmin, xmax, ymin, ymax, zmin, zmax float64)
- func AxisXmax(xmax float64)
- func AxisXmin(xmin float64)
- func AxisXrange(xmin, xmax float64)
- func AxisYmax(ymax float64)
- func AxisYmin(ymin float64)
- func AxisYrange(ymin, ymax float64)
- func Box(xmin, xmax, ymin, ymax, zmin, zmax float64, args *A)
- func C(i, palette int) string
- func CalcDiagAngle(p []float64) (alphaRad float64)
- func Camera(elev, azim float64, args *A)
- func Circle(xc, yc, r float64, args *A)
- func Clf()
- func ConeDiag(c []float64, alphaDeg float64, height float64, nu, nv int, args *A) (X, Y, Z [][]float64)
- func ConeZ(c []float64, alphaDeg float64, height float64, nu, nv int, args *A) (X, Y, Z [][]float64)
- func ContourF(x, y, z [][]float64, args *A)
- func ContourL(x, y, z [][]float64, args *A)
- func Cross(x0, y0 float64, args *A)
- func CylinderZ(c []float64, radius, height float64, nu, nv int, args *A) (X, Y, Z [][]float64)
- func Default3dView(xmin, xmax, ymin, ymax, zmin, zmax float64, equal bool)
- func DefaultTriad(length float64)
- func Diag3d(scale float64, args *A)
- func DoubleYscale(ylabelOrEmpty string)
- func Draw3dVector(p, v []float64, sf float64, normed bool, args *A)
- func DrawArrow2d(c, v []float64, normalize bool, sf float64, args *A)
- func DrawArrow3d(c, v []float64, normalize bool, sf float64, args *A)
- func Equal()
- func Gll(xl, yl string, args *A)
- func Grid(args *A)
- func Grid2d(X, Y [][]float64, withIDs bool, argsLines, argsIDs *A)
- func Grid3d(X, Y, Z [][][]float64, withIDs bool, argsLines *A, argsIDs *A)
- func Grid3dZlevels(X, Y [][]float64, Zlevels []float64, withIDs bool, argsLines, argsIDs *A)
- func Hemisphere(c []float64, r, alphaMin, alphaMax float64, nu, nv int, cup bool, args *A) (X, Y, Z [][]float64)
- func HideAllBorders()
- func HideBorders(args *A)
- func HideTRborders()
- func Hist(x [][]float64, labels []string, args *A)
- func Legend(args *A)
- func LegendX(dat []*A, args *A)
- func M(i, scheme int) string
- func PlaneZ(p, n []float64, xmin, xmax, ymin, ymax float64, nu, nv int, showPN bool, ...) (X, Y, Z [][]float64)
- func Plot(x, y []float64, args *A) (sx, sy string)
- func Plot3dLine(X, Y, Z []float64, args *A)
- func Plot3dPoint(x, y, z float64, args *A)
- func Plot3dPoints(X, Y, Z []float64, args *A)
- func PlotOne(x, y float64, args *A)
- func Polygon3d(P [][]float64, args *A)
- func Polyline(P [][]float64, args *A)
- func PyCmds(text string)
- func PyFile(filename string)
- func Quiver(x, y, gx, gy [][]float64, args *A)
- func ReplaceAxes(xi, yi, xf, yf, xDel, yDel float64, xLab, yLab string, argsArrow, argsText *A)
- func Reset(setDefault bool, args *A)
- func Save(dirout, fnkey string)
- func Sca(axName string)
- func Scale3d(xmin, xmax, ymin, ymax, zmin, zmax float64, equal bool)
- func SetAxis(xmin, xmax, ymin, ymax float64)
- func SetFontSizes(args *A)
- func SetHspace(hspace float64)
- func SetLabels(x, y string, args *A)
- func SetLabels3d(x, y, z string, args *A)
- func SetNoXtickLabels()
- func SetNoYtickLabels()
- func SetScientificX(minOrder, maxOrder int)
- func SetScientificY(minOrder, maxOrder int)
- func SetTicksNormal()
- func SetTicksRotationX(degree float64)
- func SetTicksRotationY(degree float64)
- func SetTicksX(majorEvery, minorEvery float64, majorFmt string)
- func SetTicksXlist(values []float64)
- func SetTicksY(majorEvery, minorEvery float64, majorFmt string)
- func SetTicksYlist(values []float64)
- func SetVspace(vspace float64)
- func SetXlabel(xl string, args *A)
- func SetXlog()
- func SetXnticks(num int)
- func SetYlabel(yl string, args *A)
- func SetYlog()
- func SetYnticks(num int)
- func Show()
- func ShowSave(dirout, fnkey string)
- func SlopeInd(m, xc, yc, xlen float64, lbl string, flip, xlog, ylog bool, args, argsLbl *A)
- func Sphere(c []float64, radius float64, nalp, neta int, args *A) (X, Y, Z [][]float64)
- func SplotGap(w, h float64)
- func Subplot(i, j, k int)
- func SubplotI(I []int)
- func SubplotMatrix(nrow, ncol int, cmds func(i, j int))
- func SubplotMatrixSym(nrow, ncol int, cmds func(i, j int), corner func()) (n, cornerIdx int)
- func SupTitle(txt string, args *A)
- func Superquadric(c, r, a []float64, alpMin, alpMax, etaMin, etaMax float64, nalp, neta int, ...) (X, Y, Z [][]float64)
- func Surface(X, Y, Z [][]float64, args *A)
- func TexPiRadFmt(x float64) string
- func Text(x, y float64, txt string, args *A)
- func Text3d(x, y, z float64, txt string, args *A)
- func Title(txt string, args *A)
- func Triad(length float64, xLab, yLab, zLab string, argsLines, argsText *A)
- func Waterfall(X, T []float64, Z [][]float64, args *A)
- func Wireframe(X, Y, Z [][]float64, args *A)
- func ZoomWindow(lef, bot, wid, hei float64, args *A) (axOld, axNew string)
- type A
Constants ¶
This section is empty.
Variables ¶
var TemporaryDir = "/tmp/pltgosl.py"
TemporaryDir defines the default directory to save Python (matplotlib) files
Functions ¶
func AnnotateXlabels ¶
AnnotateXlabels sets text of xlabels
func Arrow ¶
Arrow adds arrow to plot
styles: Curve - None CurveB -> head_length=0.4,head_width=0.2 BracketB -[ widthB=1.0,lengthB=0.2,angleB=None CurveFilledB -|> head_length=0.4,head_width=0.2 CurveA <- head_length=0.4,head_width=0.2 CurveAB <-> head_length=0.4,head_width=0.2 CurveFilledA <|- head_length=0.4,head_width=0.2 CurveFilledAB <|-|> head_length=0.4,head_width=0.2 BracketA ]- widthA=1.0,lengthA=0.2,angleA=None BracketAB ]-[ widthA=1.0,lengthA=0.2,angleA=None,widthB=1.0,lengthB=0.2,angleB=None Fancy fancy head_length=0.4,head_width=0.4,tail_width=0.4 Simple simple head_length=0.5,head_width=0.5,tail_width=0.2 Wedge wedge tail_width=0.3,shrink_factor=0.5 BarAB |-| widthA=1.0,angleA=None,widthB=1.0,angleB=None
func AxDist ¶
func AxDist(dist float64)
AxDist sets distance in 3d graph. e.g. to avoid clipping due to tight bbox
func AxisRange ¶
func AxisRange(xmin, xmax, ymin, ymax float64)
AxisRange sets x and y ranges (i.e. limits)
func AxisRange3d ¶
func AxisRange3d(xmin, xmax, ymin, ymax, zmin, zmax float64)
AxisRange3d sets x, y, and z ranges (i.e. limits)
func Box ¶
Box draws box
NOTE: args.Wire and args.Ls are used to draw a wire around the edges of the box
func C ¶ added in v1.0.1
C returns a color from a default palette
use palette < 0 for automatic color
func CalcDiagAngle ¶
CalcDiagAngle computes the angle between a point and the diagonal of the 3d space
p -- point coordinates returns the angle in radians
func Camera ¶
Camera sets camera in 3d graph. Sets the elevation and azimuth of the axes.
elev -- is the elevation angle in the z plane azim -- is the azimuth angle in the x,y plane
func ConeDiag ¶
func ConeDiag(c []float64, alphaDeg float64, height float64, nu, nv int, args *A) (X, Y, Z [][]float64)
ConeDiag draws cone parallel to the diagonal of the 3d space
Input: c -- centre coordinates. may be nil alphaDeg -- half opening angle in degrees height -- height of cone; i.e. length along space diagonal nu -- number of divisions along the height of cone; e.g. 11 nv -- number of divisions along circumference of cone; e.g. 21 Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func ConeZ ¶
func ConeZ(c []float64, alphaDeg float64, height float64, nu, nv int, args *A) (X, Y, Z [][]float64)
ConeZ draws cone aligned with the z axis
Input: c -- centre coordinates. may be nil alphaDeg -- half opening angle in degrees height -- height of cone nu -- number of divisions along the height of cone; e.g. 11 nv -- number of divisions along circumference of cone; e.g. 21 Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func ContourF ¶
ContourF draws filled contour and possibly with a contour of lines (if args.UnoLines=false)
func CylinderZ ¶
CylinderZ draws cylinder aligned with the z axis
Input: c -- centre coordinates. may be nil alphaDeg -- half opening angle in degrees height -- height of cone nu -- number of divisions along the height of cone; e.g. 11 nv -- number of divisions along circumference of cone; e.g. 21 Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func Default3dView ¶
Default3dView sets default 3d view (camera and scale)
func DefaultTriad ¶
func DefaultTriad(length float64)
DefaultTriad adds triad with default colors and labels
func Draw3dVector ¶
Draw3dVector adds segment to figure
p -- starting point v -- vector sf -- scale factor normed -- normalised
func DrawArrow2d ¶ added in v1.1.0
DrawArrow2d draws 2d arrow @ c with direction v
func DrawArrow3d ¶ added in v1.1.0
DrawArrow3d draws 3d arrow @ c with direction v
func Grid2d ¶
Grid2d draws grid lines of 2D grid
withIDs -- add text with IDs numbered by looping over {X,Y}[j][i] (j:outer, i:inner)
func Grid3d ¶
Grid3d draws grid lines of 3D grid
withIDs -- add text with IDs numbered by looping over {X,Y,Z}[k][j][i] (k:outer, j:mid, i:inner)
func Grid3dZlevels ¶ added in v1.1.0
Grid3dZlevels draws grid lines of 3D grid
withIDs -- add text with IDs numbered by looping over {X,Y,Z}[k][j][i] (k:outer, j:mid, i:inner)
func Hemisphere ¶
func Hemisphere(c []float64, r, alphaMin, alphaMax float64, nu, nv int, cup bool, args *A) (X, Y, Z [][]float64)
Hemisphere draws Hemisphere
Input: c -- centre coordinates. may be nil r -- radius alphaMin -- minimum circumference angle (degrees) alphaMax -- minimum circumference angle (degrees) nu -- number of divisions along one direction on plane nv -- number of divisions along the orther direction on plane cup -- upside-down; like a cup surface -- generate surface wireframe -- generate wireframe Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func PlaneZ ¶
func PlaneZ(p, n []float64, xmin, xmax, ymin, ymax float64, nu, nv int, showPN bool, args *A) (X, Y, Z [][]float64)
PlaneZ draws a plane that has a normal vector with non-zero z component. The plane may be perpendicular to z.
Input: p -- point on plane n -- normal vector nu -- number of divisions along one direction on plane nv -- number of divisions along the orther direction on plane showPN -- show point and normal Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func PyFile ¶
func PyFile(filename string)
PyFile loads Python file and copy its contents to temporary buffer
func ReplaceAxes ¶
ReplaceAxes substitutes axis frame (see Axes in gosl.py)
ex: xDel, yDel := 0.04, 0.04
func Reset ¶
Reset resets drawing buffer (i.e. Python temporary file data) and sets figure data.
NOTE: This function is optional; i.e. plt works without calling this function. Nonetheless, if fontsizes or figure sizes need to be specified, Reset can be called. Input: setDefault -- sets default values args -- optional data (may be nil) NOTE: Default values are selected if setDefault == true. Otherwise, Python (matplotlib) will choose defaults. Also, if args != nil, some values are set based on data in args. The following data is set: fontsizes: args.Fsz float64 // font size args.FszLbl float64 // font size of labels args.FszLeg float64 // font size of legend args.FszXtck float64 // font size of x-ticks args.FszYtck float64 // font size of y-ticks figure data: args.Dpi int // dpi to be used when saving figure. default = 96 args.Png bool // save png file args.Eps bool // save eps file args.Prop float64 // proportion: height = width * prop args.WidthPt float64 // width in points. Get this from LaTeX using \showthe\columnwidth
func Save ¶
func Save(dirout, fnkey string)
Save saves figure after creating a directory
NOTE: the file name will be fnkey + .png (default) or .eps depending on the Reset function
func SetFontSizes ¶
func SetFontSizes(args *A)
SetFontSizes sets font sizes
NOTE: this function also sets the FontSet, if not ""
func SetNoXtickLabels ¶ added in v1.0.1
func SetNoXtickLabels()
SetNoXtickLabels hides labels of x-ticks but keep ticks
func SetNoYtickLabels ¶ added in v1.0.1
func SetNoYtickLabels()
SetNoYtickLabels hides labels of y-ticks but keep ticks
func SetScientificX ¶
func SetScientificX(minOrder, maxOrder int)
SetScientificX sets scientific notation for ticks along x-axis
func SetScientificY ¶
func SetScientificY(minOrder, maxOrder int)
SetScientificY sets scientific notation for ticks along y-axis
func SetTicksRotationX ¶
func SetTicksRotationX(degree float64)
SetTicksRotationX sets the rotation angle of x-ticks
func SetTicksRotationY ¶
func SetTicksRotationY(degree float64)
SetTicksRotationY sets the rotation angle of y-ticks
func SetTicksXlist ¶
func SetTicksXlist(values []float64)
SetTicksXlist sets x-axis ticks with given list
func SetTicksYlist ¶
func SetTicksYlist(values []float64)
SetTicksYlist sets y-ayis ticks with given list
func Sphere ¶ added in v1.0.1
Sphere draws sphere
Input: c -- centre coordinates. may be nil => (0,0,0) will be considered r -- radius nalp -- number of divisions along α neta -- number of divisions along η Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func SubplotMatrix ¶ added in v1.0.1
SubplotMatrix call plotCommands to fill a matrix of plots
Input: nrow -- number of rows in matrix [must be at least 1] ncol -- number of columns in matrix [must be at least 1] cmds -- plotting commants for each (i,j) grid point (NOT Subplot indices)
func SubplotMatrixSym ¶ added in v1.0.1
SubplotMatrixSym call plotCommands to fill a symmetric matrix of plots (excluding the diagonal)
Input: nrow -- number of rows in matrix including diagonal [must be at least 2] ncol -- number of columns in matrix including diagonal[must be at least 2] cmds -- plotting commants for each (i,j) grid point (NOT Subplot indices) corner -- function to be called to draw on "corner" of matrix (left-bottom side) Output: n -- the effective number of columns == min(nrow-1,ncol-1) cornerIdx -- the subplot index of "corner" graph NOTE: the resulting grid will be (n×n)
func Superquadric ¶
func Superquadric(c, r, a []float64, alpMin, alpMax, etaMin, etaMax float64, nalp, neta int, args *A) (X, Y, Z [][]float64)
Superquadric draws superquadric (i.e. superellipsoid)
Input: c -- centre coordinates. may be nil => (0,0,0) will be considered r -- radii [3] a -- exponents [3] alpMin -- min alp angle. in [-180, 180) degrees alpMax -- max alp angle. in (-180, 180] degrees etaMin -- min eta angle. in [-90, 90) degrees etaMax -- max eta angle. in (-90, 90] degrees nalp -- number of divisions along α neta -- number of divisions along η Output: X, Y, Z -- the coordinates of all points as in a meshgrid
func TexPiRadFmt ¶
TexPiRadFmt formats number in radians/pi notation
func Triad ¶
Triad draws icon indicating x-y-z origin and direction
xLab, yLab, zLab -- labels. may be empty
func Waterfall ¶ added in v1.0.1
Waterfall draws parallel lines @ t along x with height = z. z[len(t)][len(x)]
func ZoomWindow ¶
ZoomWindow adds another axes to plot a figure within the figure; e.g. a zoom window
lef, bot, wid, hei -- normalised figure coordinates: left,bottom,width,height asOld -- handle to the previous axes axNew -- handle to the new axes
Types ¶
type A ¶
type A struct { // plot and basic options C string // color A float64 // transparency coefficient M string // marker Ls string // linestyle Lw float64 // linewidth; -1 => default Ms int // marker size; -1 => default L string // label Me int // mark-every; -1 => default Z int // z-order Mec string // marker edge color Mew float64 // marker edge width Void bool // void marker => markeredgecolor='C', markerfacecolor='none' NoClip bool // turn clipping off // shapes Fc string // shapes: face color Ec string // shapes: edge color Scale float64 // shapes: scale information Style string // shapes: style information Closed bool // shapes: closed shape // text and extra arguments Ha string // horizontal alignment; e.g. 'center' Va string // vertical alignment; e.g. 'center' Rot float64 // rotation Fsz float64 // font size FszLbl float64 // font size of labels FszLeg float64 // font size of legend FszXtck float64 // font size of x-ticks FszYtck float64 // font size of y-ticks FontSet string // font set: e.g. 'stix', 'stixsans' [default] HideL bool // hide left frame border HideR bool // hide right frame border HideB bool // hide bottom frame border HideT bool // hide top frame border // other options AxCoords bool // the given x-y coordinates correspond to axes coords FigCoords bool // the given x-y coordinates correspond to figure coords // legend LegLoc string // legend: location. e.g.: right, center left, upper right, lower right, best, center, lower left, center right, upper left, upper center, lower center LegNcol int // legend: number of columns LegHlen float64 // legend: handle length LegFrame bool // legend: frame on LegOut bool // legend: outside LegOutX []float64 // legend: normalised coordinates to put legend outside frame // colors for contours or histograms Colors []string // contour or histogram: colors // contours Nlevels int // contour: number of levels (overridden by Levels when it's not nil) Levels []float64 // contour: levels (may be nil) CmapIdx int // contour: colormap index NumFmt string // contour: number format; e.g. "%g" or "%.2f" NoLines bool // contour: do not add lines on top of filled contour NoLabels bool // contour: do not add labels NoInline bool // contour: do not draw labels 'inline' NoCbar bool // contour: do not add colorbar CbarLbl string // contour: colorbar label SelectV float64 // contour: selected value SelectC string // contour: color to mark selected level. empty means no selected line SelectLw float64 // contour: zero level linewidth // 3d graphs Rstride int // 3d: row stride Cstride int // 3d: column stride Surf bool // 3d: generate surface Wire bool // 3d: generate wireframe // histograms Type string // histogram: type; e.g. "bar" Stacked bool // histogram: stacked NoFill bool // histogram: do not fill bars Nbins int // histogram: number of bins Normed bool // histogram: normed // figures Dpi int // figure: dpi to be used when saving figure. default = 96 Png bool // figure: save png file Eps bool // figure: save eps file Prop float64 // figure: proportion: height = width * prop WidthPt float64 // figure: width in points. Get this from LaTeX using \showthe\columnwidth }
The A structure holds arguments to configure plots, including style data for shapes (e.g. polygons)