References
Contents
Index
Base.Multimedia.display
Plots.abline!
Plots.addExtension
Plots.annotate!
Plots.areaplot
Plots.arrow
Plots.backend_object
Plots.bar
Plots.bar!
Plots.barhist
Plots.barhist!
Plots.bbox
Plots.boxplot
Plots.boxplot!
Plots.center
Plots.closeall
Plots.contour
Plots.contour!
Plots.contourf
Plots.contourf!
Plots.coords
Plots.current
Plots.curves
Plots.curves!
Plots.default
Plots.density
Plots.density!
Plots.eps
Plots.font
Plots.frame
Plots.gif
Plots.gui
Plots.heatmap
Plots.heatmap!
Plots.hexbin
Plots.hexbin!
Plots.histogram
Plots.histogram!
Plots.histogram2d
Plots.histogram2d!
Plots.hline
Plots.hline!
Plots.hspan
Plots.hspan!
Plots.html
Plots.json
Plots.lens!
Plots.makeshape
Plots.makestar
Plots.mesh3d
Plots.mesh3d!
Plots.mov
Plots.mp4
Plots.ohlc
Plots.ohlc!
Plots.partialcircle
Plots.path3d
Plots.path3d!
Plots.pdf
Plots.pie
Plots.pie!
Plots.plot3d
Plots.plotattr
Plots.png
Plots.ps
Plots.quiver
Plots.quiver!
Plots.rotate
Plots.savefig
Plots.scale
Plots.scalefontsizes
Plots.scalefontsizes
Plots.scatter
Plots.scatter!
Plots.scatter3d
Plots.scatter3d!
Plots.scatterhist
Plots.scatterhist!
Plots.stephist
Plots.stephist!
Plots.sticks
Plots.sticks!
Plots.stroke
Plots.surface
Plots.surface!
Plots.svg
Plots.tex
Plots.text
Plots.theme
Plots.title!
Plots.translate
Plots.txt
Plots.violin
Plots.violin!
Plots.vline
Plots.vline!
Plots.vspan
Plots.vspan!
Plots.weave
Plots.webm
Plots.wireframe
Plots.wireframe!
Plots.with
Plots.xaxis!
Plots.xerror
Plots.xerror!
Plots.xflip!
Plots.xgrid!
Plots.xlabel!
Plots.xlims
Plots.xlims!
Plots.xticks!
Plots.yaxis!
Plots.yerror
Plots.yerror!
Plots.yflip!
Plots.ygrid!
Plots.ylabel!
Plots.ylims
Plots.ylims!
Plots.yticks!
Plots.zaxis!
Plots.zerror
Plots.zerror!
Plots.zflip!
Plots.zgrid!
Plots.zlabel!
Plots.zlims
Plots.zlims!
Plots.zticks!
RecipesBase.animate
RecipesBase.grid
RecipesBase.plot
Plots.@animate
Plots.@gif
RecipesBase.@layout
Public Interface
Plot specification
RecipesBase.plot
— FunctionThe main plot command. Use plot
to create a new plot object, and plot!
to add to an existing one:
plot(args...; kw...) # creates a new plot window, and sets it to be the current
plot!(args...; kw...) # adds to the `current`
plot!(plotobj, args...; kw...) # adds to the plot `plotobj`
There are lots of ways to pass in data, and lots of keyword arguments... just try it and it will likely work as expected. When you pass in matrices, it splits by columns. To see the list of available attributes, use the plotattr(attr)
function, where attr
is the symbol :Series
, :Subplot
, :Plot
, or :Axis
. Pass any attribute to plotattr
as a String to look up its docstring, e.g., plotattr("seriestype")
.
Extended help
Series attributes
- arrow
- bar_edges
- bar_position
- bar_width
- bins
- colorbar_entry
- connections
- contour_labels
- contours
- extra_kwargs
- fill
- fill_z
- fillalpha
- fillcolor
- fillrange
- fillstyle
- group
- hover
- label
- levels
- line
- line_z
- linealpha
- linecolor
- linestyle
- linewidth
- marker
- marker_z
- markeralpha
- markercolor
- markershape
- markersize
- markerstrokealpha
- markerstrokecolor
- markerstrokestyle
- markerstrokewidth
- normalize
- orientation
- permute
- primary
- quiver
- ribbon
- series_annotations
- seriesalpha
- seriescolor
- seriestype
- show_empty_bins
- smooth
- stride
- subplot
- weights
- x
- xerror
- y
- yerror
- z
- z_order
- zerror
Axis attributes
Prepend these with the axis letter (x, y or z)
- axis
- discrete_values
- draw_arrow
- flip
- foreground_color_axis
- foreground_color_border
- foreground_color_grid
- foreground_color_guide
- foreground_color_minor_grid
- foreground_color_text
- formatter
- grid
- gridalpha
- gridlinewidth
- gridstyle
- guide
- guide_position
- guidefont
- guidefontcolor
- guidefontfamily
- guidefonthalign
- guidefontrotation
- guidefontsize
- guidefontvalign
- lims
- link
- minorgrid
- minorgridalpha
- minorgridlinewidth
- minorgridstyle
- minorticks
- mirror
- rotation
- scale
- showaxis
- tick_direction
- tickfont
- tickfontcolor
- tickfontfamily
- tickfonthalign
- tickfontrotation
- tickfontsize
- tickfontvalign
- ticks
- unitformat
- widen
Subplot attributes
- annotationcolor
- annotationfontfamily
- annotationfontsize
- annotationhalign
- annotationrotation
- annotations
- annotationvalign
- aspect_ratio
- background_color_inside
- background_color_subplot
- bottom_margin
- camera
- clims
- color_palette
- colorbar
- colorbar_continuous_values
- colorbar_discrete_values
- colorbar_fontfamily
- colorbar_formatter
- colorbar_scale
- colorbar_tickfontcolor
- colorbar_tickfontfamily
- colorbar_tickfonthalign
- colorbar_tickfontrotation
- colorbar_tickfontsize
- colorbar_tickfontvalign
- colorbar_ticks
- colorbar_title
- colorbar_title_location
- colorbar_titlefont
- colorbar_titlefontcolor
- colorbar_titlefontfamily
- colorbar_titlefonthalign
- colorbar_titlefontrotation
- colorbar_titlefontsize
- colorbar_titlefontvalign
- extra_kwargs
- fontfamily_subplot
- foreground_color_subplot
- foreground_color_title
- framestyle
- left_margin
- legend_background_color
- legend_column
- legend_font
- legend_font_color
- legend_font_family
- legend_font_halign
- legend_font_pointsize
- legend_font_rotation
- legend_font_valign
- legend_foreground_color
- legend_position
- legend_title
- legend_title_font
- legend_title_font_color
- legend_title_font_family
- legend_title_font_halign
- legend_title_font_pointsize
- legend_title_font_rotation
- legend_title_font_valign
- margin
- plot_title_font
- projection
- projection_type
- right_margin
- subplot_index
- title
- title_font
- titlefontcolor
- titlefontfamily
- titlefonthalign
- titlefontrotation
- titlefontsize
- titlefontvalign
- titlelocation
- top_margin
Plot attributes
- background_color
- background_color_outside
- display_type
- dpi
- extra_kwargs
- extra_plot_kwargs
- fontfamily
- foreground_color
- html_output_format
- inset_subplots
- layout
- link
- overwrite_figure
- plot_title
- plot_titlefontcolor
- plot_titlefontfamily
- plot_titlefonthalign
- plot_titlefontrotation
- plot_titlefontsize
- plot_titlefontvalign
- plot_titleindex
- plot_titlelocation
- plot_titlevspan
- pos
- show
- size
- tex_output_standalone
- thickness_scaling
- warn_on_unsupported
- window_title
Extract a subplot from an existing plot.
Examples
julia> p1, p2 = plot(1:2), plot(10:20)
julia> pl = plot(p1, p2) # plot containing 2 subplots
julia> plot(pl.subplots[1]) # extract 1st subplot as a standalone plot
julia> plot(pl.subplots[2]) # extract 2nd subplot as a standalone plot
Plots.bbox
— Functionbbox(x, y, w, h [,originargs...])
bbox(layout)
Create a bounding box for plotting
RecipesBase.grid
— Functiongrid(args...; kw...)
Create a grid layout for subplots. args
specify the dimensions, e.g. grid(3,2, widths = (0.6,0.4))
creates a grid with three rows and two columns of different width.
RecipesBase.@layout
— Macro@layout mat
Generate the subplots layout from a matrix of symbols (where subplots can span multiple rows or columns). Precise sizing can be achieved with curly brackets, otherwise the free space is equally split between the plot areas of subplots. You can use the _
character (underscore) to ignore plots in the layout (blank plots).
Examples
julia> @layout [a b; c]
2×1 Matrix{Any}:
Any[(label = :a, blank = false) (label = :b, blank = false)]
(label = :c, blank = false)
julia> @layout [a{0.3w}; b{0.2h}]
2×1 Matrix{Any}:
(label = :a, width = 0.3, height = :auto)
(label = :b, width = :auto, height = 0.2)
julia> @layout [_ ° _; ° ° °; ° ° °]
3×3 Matrix{Any}:
(label = :_, blank = true) … (label = :_, blank = true)
(label = :°, blank = false) (label = :°, blank = false)
(label = :°, blank = false) (label = :°, blank = false)
Plots.default
— Functiondefault(key)
returns the current default value for that key.
default(key, value)
sets the current default value for that key.
default(; kw...)
will set the current default value for each key/value pair.
default(plotattributes, key)
returns the key from plotattributes if it exists, otherwise default(key)
.
Plots.theme
— Functiontheme(s::Symbol)
Specify the colour theme for plots.
Plots.with
— FunctionAllows temporary setting of backend and defaults for Plots. Settings apply only for the do
block. Example:
with(:gr, size=(400,400), type=:histogram) do
plot(rand(10))
plot(rand(10))
end
Plots.arrow
— Methodarrow(args...)
Define arrowheads to apply to lines - args are style
(:open
or :closed
), side
(:head
, :tail
or :both
), headlength
and headwidth
Plots.center
— Methodreturn the centroid of a Shape
Plots.coords
— Methodreturn the vertex points from a Shape or Segments object
Plots.font
— Methodfont(args...)
Create a Font from a list of features. Values may be specified either as arguments (which are distinguished by type/value) or as keyword arguments.
Arguments
family
: AbstractString. "serif" or "sans-serif" or "monospace"pointsize
: Integer. Size of font in pointshalign
: Symbol. Horizontal alignment (:hcenter, :left, or :right)valign
: Symbol. Vertical alignment (:vcenter, :top, or :bottom)rotation
: Real. Angle of rotation for text in degrees (use a non-integer type)color
: Colorant or Symbol
Examples
julia> font(8)
julia> font(family="serif", halign=:center, rotation=45.0)
Plots.makeshape
— Methodcreate a shape by picking points around the unit circle. n
is the number of point/sides, offset
is the starting angle
Plots.makestar
— Methodcreate a star by weaving together points from an outer and inner circle. n
is the number of arms
Plots.partialcircle
— Functionget an array of tuples of points on a circle with radius r
Plots.rotate
— Functionrotate an object in space
Plots.scale
— Functionscale(shape, x, y = x, c = center(shape))
scale!(shape, x, y = x, c = center(shape))
Scale shape by a factor.
Plots.scalefontsizes
— Methodscalefontsizes(factor::Number)
Scales all current font sizes by factor
. For example scalefontsizes(1.1)
increases all current font sizes by 10%. To reset to initial sizes, use scalefontsizes()
Plots.scalefontsizes
— Methodscalefontsizes()
Resets font sizes to initial default values.
Plots.stroke
— Methodstroke(args...; alpha = nothing)
Define the properties of the stroke used in plotting lines
Plots.text
— Methodtext(string, args...; kw...)
Create a PlotText object wrapping a string with font info, for plot annotations. args
and kw
are passed to font
.
Plots.translate
— Functiontranslate(shape, x, y = x)
translate!(shape, x, y = x)
Translate a Shape in space.
Plots.weave
— Methodinterleave 2 vectors into each other (like a zipper's teeth)
Plots.abline!
— Functionabline!([plot,] a, b; kwargs...)
Adds ax+b... straight line over the current plot, without changing the axis limits
Plots.annotate!
— Methodannotate!(anns)
annotate!(anns::Tuple...)
annotate!(x, y, txt)
Add annotations to an existing plot. Annotations are specified either as a vector of tuples, each of the form (x,y,txt)
, or as three vectors, x, y, txt
. Each txt
can be a String
, PlotText
PlotText (created with text(args...)
), or a tuple of arguments to text
(e.g., ("Label", 8, :red, :top)
).
Example
julia> plot(1:10)
julia> annotate!([(7,3,"(7,3)"),(3,7,text("hey", 14, :left, :top, :green))])
julia> annotate!([(4, 4, ("More text", 8, 45.0, :bottom, :red))])
julia> annotate!([2,5], [6,3], ["text at (2,6)", "text at (5,3)"])
Plots.areaplot
— Functionareaplot([x,] y)
areaplot!([x,] y)
Draw a stacked area plot of the matrix y.
Examples
julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], fillalpha = [0.2 0.3 0.4])
Plots.bar!
— Methodbar(x,y)
bar!(x,y)
Make a bar plot of y
vs x
.
Keyword arguments
bar_position::Symbol
: Choose from:overlay
(default),:stack
. (warning: may only be partially implemented). Aliases: (:bar_positions, :barpositions).bar_width::Real
: Width of bars in data coordinates. Whennothing
, chooses based onx
(ory
whenorientation = :h
). Aliases: (:bar_widths, :barwidths).bar_edges::Bool
: Align bars to edges (true), or centers (the default) ?.fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).permute::Tuple{Symbol, Symbol}
: Permutes data and axis properties of the axes given in the tuple, e.g. (:x, :y). Aliases: (:permutes,).
Examples
julia> bar([1,2,3],[4,5,6],fillcolor=[:red,:green,:blue],fillalpha=[0.2,0.4,0.6])
julia> bar([(1,4),(2,5),(3,6)])
Plots.bar
— Methodbar(x,y)
bar!(x,y)
Make a bar plot of y
vs x
.
Keyword arguments
bar_position::Symbol
: Choose from:overlay
(default),:stack
. (warning: may only be partially implemented). Aliases: (:bar_positions, :barpositions).bar_width::Real
: Width of bars in data coordinates. Whennothing
, chooses based onx
(ory
whenorientation = :h
). Aliases: (:bar_widths, :barwidths).bar_edges::Bool
: Align bars to edges (true), or centers (the default) ?.fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).permute::Tuple{Symbol, Symbol}
: Permutes data and axis properties of the axes given in the tuple, e.g. (:x, :y). Aliases: (:permutes,).
Examples
julia> bar([1,2,3],[4,5,6],fillcolor=[:red,:green,:blue],fillalpha=[0.2,0.4,0.6])
julia> bar([(1,4),(2,5),(3,6)])
Plots.barhist!
— Methodbarhist(x)
barhist!(x)
Make a histogram bar plot. See histogram
.
Plots.barhist
— Methodbarhist(x)
barhist!(x)
Make a histogram bar plot. See histogram
.
Plots.boxplot!
— Methodboxplot(x, y)
boxplot!(x, y)
Make a box and whisker plot.
Keyword arguments
notch
: Bool. Notch the box plot? (false)whisker_range
: Real. Whiskers extendwhisker_range
*IQR below the first quartile and above the third quartile. Values outside this range are shown as outliers (1.5)outliers
: Bool. Show outliers? (true)whisker_width
: Real or Symbol. Length of whiskers; the options are:match
to match the box width,:half
, or a number to indicate the total length. (:half)
Example
julia> using StatsPlots
julia> boxplot(repeat([1,2,3],outer=100),randn(300))
Plots.boxplot
— Methodboxplot(x, y)
boxplot!(x, y)
Make a box and whisker plot.
Keyword arguments
notch
: Bool. Notch the box plot? (false)whisker_range
: Real. Whiskers extendwhisker_range
*IQR below the first quartile and above the third quartile. Values outside this range are shown as outliers (1.5)outliers
: Bool. Show outliers? (true)whisker_width
: Real or Symbol. Length of whiskers; the options are:match
to match the box width,:half
, or a number to indicate the total length. (:half)
Example
julia> using StatsPlots
julia> boxplot(repeat([1,2,3],outer=100),randn(300))
Plots.contour!
— Methodcontour(x,y,z)
contour!(x,y,z)
Draw contour lines of the surface z
.
Arguments
levels
: Contour levels (ifAbstractVector
) or number of levels (ifInteger
)fill
: Bool. Fill area between contours or draw contours only (false by default)
Example
julia> x = y = range(-20, stop = 20, length = 100)
julia> contour(x, y, (x, y) -> x^2 + y^2)
Plots.contour
— Methodcontour(x,y,z)
contour!(x,y,z)
Draw contour lines of the surface z
.
Arguments
levels
: Contour levels (ifAbstractVector
) or number of levels (ifInteger
)fill
: Bool. Fill area between contours or draw contours only (false by default)
Example
julia> x = y = range(-20, stop = 20, length = 100)
julia> contour(x, y, (x, y) -> x^2 + y^2)
Plots.contourf!
— MethodAn alias for contour
with fill = true.
Plots.contourf
— MethodAn alias for contour
with fill = true.
Plots.curves!
— Methodcurves(x,y)
curves!(x,y)
Draw a Bezier curve from (x[1],y[1])
to (x[end],y[end])
with control points (x[2],y[2]), ..., (x[end-1],y[end]-1)
.
Keyword arguments
fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).
Example
julia> curves([1,2,3,4],[1,1,2,4])
Plots.curves
— Methodcurves(x,y)
curves!(x,y)
Draw a Bezier curve from (x[1],y[1])
to (x[end],y[end])
with control points (x[2],y[2]), ..., (x[end-1],y[end]-1)
.
Keyword arguments
fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).
Example
julia> curves([1,2,3,4],[1,1,2,4])
Plots.density!
— Methoddensity(x)
density!(x)
Make a line plot of a kernel density estimate of x. The smoothness of the density plot is defined from bandwidth
(real positive number).
Arguments
x
: AbstractVector of samples for probability density estimation
Keyword arguments
trim
::Bool: enables cutting off the distribution tails.bandwidth
::Number: a low bandwidth induces under-smoothing, whilst a high bandwidth induces over-smoothing.
Examples
julia> density(randn(100), bandwidth = -0.01, trim = false)
output : ERROR: Bandwidth must be positive
julia> density(randn(100), bandwidth = 0.1, trim = false) # a curve with extremity and under-smoothing
julia> density(randn(100), bandwidth = 10, trim = true) # a curve without extremity and over-smoothing
Example
julia> using StatsPlots
julia> density(randn(100_000))
Plots.density
— Methoddensity(x)
density!(x)
Make a line plot of a kernel density estimate of x. The smoothness of the density plot is defined from bandwidth
(real positive number).
Arguments
x
: AbstractVector of samples for probability density estimation
Keyword arguments
trim
::Bool: enables cutting off the distribution tails.bandwidth
::Number: a low bandwidth induces under-smoothing, whilst a high bandwidth induces over-smoothing.
Examples
julia> density(randn(100), bandwidth = -0.01, trim = false)
output : ERROR: Bandwidth must be positive
julia> density(randn(100), bandwidth = 0.1, trim = false) # a curve with extremity and under-smoothing
julia> density(randn(100), bandwidth = 10, trim = true) # a curve without extremity and over-smoothing
Example
julia> using StatsPlots
julia> density(randn(100_000))
Plots.heatmap!
— Methodheatmap(x,y,z)
heatmap!(x,y,z)
Plot a heatmap of the rectangular array z
.
Keyword arguments
aspect_ratio::Union{Real, Symbol}
: Plot area is resized so that 1 y-unit is the same size asaspect_ratio
x-units. With:none
, images inherit aspect ratio of the plot area. Use:equal
for unit aspect ratio. Aliases: (:aspectratios, :aspectratio, :aspectratios, :axisratio, :axisratio, :ratio).
Example
julia> heatmap(randn(10,10))
Plots.heatmap
— Methodheatmap(x,y,z)
heatmap!(x,y,z)
Plot a heatmap of the rectangular array z
.
Keyword arguments
aspect_ratio::Union{Real, Symbol}
: Plot area is resized so that 1 y-unit is the same size asaspect_ratio
x-units. With:none
, images inherit aspect ratio of the plot area. Use:equal
for unit aspect ratio. Aliases: (:aspectratios, :aspectratio, :aspectratios, :axisratio, :axisratio, :ratio).
Example
julia> heatmap(randn(10,10))
Plots.hexbin!
— Methodhexbin(x,y)
hexbin!(x,y)
Make a hexagonal binning plot (a histogram of the observations (x[i],y[i])
with hexagonal bins).
Example
julia> hexbin(randn(10_000), randn(10_000))
Plots.hexbin
— Methodhexbin(x,y)
hexbin!(x,y)
Make a hexagonal binning plot (a histogram of the observations (x[i],y[i])
with hexagonal bins).
Example
julia> hexbin(randn(10_000), randn(10_000))
Plots.histogram!
— Methodhistogram(x)
histogram!(x)
Plot a histogram.
Arguments
x
: AbstractVector of values to be binnedbins::Union{Integer, Symbol, Tuple{Integer, Integer}, AbstractVector}
: Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g.range(minimum(x), stop = maximum(x), length = 25)
. Aliases: (:bin, :nb, :nbin, :nbins).weights
: Vector of weights for the values inx
, for weighted bin countsnormalize::Union{Bool, Symbol}
: Histogram normalization mode. Possible values are: false/:none (no normalization, default), true/:pdf (normalize to a discrete PDF, where the total area of the bins is 1), :probability (bin heights sum to 1) and :density (the area of each bin, rather than the height, is equal to the counts - useful for uneven bin sizes). Aliases: (:norm, :normalized, :normalizes, :normed).bar_position::Symbol
: Choose from:overlay
(default),:stack
. (warning: may only be partially implemented). Aliases: (:bar_positions, :barpositions).bar_width::Real
: Width of bars in data coordinates. Whennothing
, chooses based onx
(ory
whenorientation = :h
). Aliases: (:bar_widths, :barwidths).bar_edges::Bool
: Align bars to edges (true), or centers (the default) ?.permute::Tuple{Symbol, Symbol}
: Permutes data and axis properties of the axes given in the tuple, e.g. (:x, :y). Aliases: (:permutes,).
Example
julia> histogram([1,2,1,1,4,3,8],bins=0:8)
julia> histogram([1,2,1,1,4,3,8],bins=0:8,weights=weights([4,7,3,9,12,2,6]))
Plots.histogram
— Methodhistogram(x)
histogram!(x)
Plot a histogram.
Arguments
x
: AbstractVector of values to be binnedbins::Union{Integer, Symbol, Tuple{Integer, Integer}, AbstractVector}
: Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g.range(minimum(x), stop = maximum(x), length = 25)
. Aliases: (:bin, :nb, :nbin, :nbins).weights
: Vector of weights for the values inx
, for weighted bin countsnormalize::Union{Bool, Symbol}
: Histogram normalization mode. Possible values are: false/:none (no normalization, default), true/:pdf (normalize to a discrete PDF, where the total area of the bins is 1), :probability (bin heights sum to 1) and :density (the area of each bin, rather than the height, is equal to the counts - useful for uneven bin sizes). Aliases: (:norm, :normalized, :normalizes, :normed).bar_position::Symbol
: Choose from:overlay
(default),:stack
. (warning: may only be partially implemented). Aliases: (:bar_positions, :barpositions).bar_width::Real
: Width of bars in data coordinates. Whennothing
, chooses based onx
(ory
whenorientation = :h
). Aliases: (:bar_widths, :barwidths).bar_edges::Bool
: Align bars to edges (true), or centers (the default) ?.permute::Tuple{Symbol, Symbol}
: Permutes data and axis properties of the axes given in the tuple, e.g. (:x, :y). Aliases: (:permutes,).
Example
julia> histogram([1,2,1,1,4,3,8],bins=0:8)
julia> histogram([1,2,1,1,4,3,8],bins=0:8,weights=weights([4,7,3,9,12,2,6]))
Plots.histogram2d!
— Methodhistogram2d(x,y)
histogram2d!(x,y)
Plot a two-dimensional histogram.
Arguments
bins
: Number of bins (if anInteger
) or bin edges (if anAbtractVector
)weights
: Vector of weights for the values inx
. Each entry of x contributes its weight to the height of its bin.
Example
julia> histogram2d(randn(10_000),randn(10_000))
Plots.histogram2d
— Methodhistogram2d(x,y)
histogram2d!(x,y)
Plot a two-dimensional histogram.
Arguments
bins
: Number of bins (if anInteger
) or bin edges (if anAbtractVector
)weights
: Vector of weights for the values inx
. Each entry of x contributes its weight to the height of its bin.
Example
julia> histogram2d(randn(10_000),randn(10_000))
Plots.hline!
— Methodhline(y)
hline!(y)
Draw horizontal lines at positions specified by the values in the AbstractVector y
.
Example
julia> hline([-1,0,2])
Plots.hline
— Methodhline(y)
hline!(y)
Draw horizontal lines at positions specified by the values in the AbstractVector y
.
Example
julia> hline([-1,0,2])
Plots.hspan!
— Methodhspan(y)
Draw a rectangle between the horizontal line at position y[1]
and the horizontal line at position y[2]
. If length(y) ≥ 4
, then further rectangles are drawn between y[3]
and y[4]
, y[5]
and y[6]
, and so on. If length(y)
is odd, then the last entry of y
is ignored.
Example
julia> hspan(1:6)
Plots.hspan
— Methodhspan(y)
Draw a rectangle between the horizontal line at position y[1]
and the horizontal line at position y[2]
. If length(y) ≥ 4
, then further rectangles are drawn between y[3]
and y[4]
, y[5]
and y[6]
, and so on. If length(y)
is odd, then the last entry of y
is ignored.
Example
julia> hspan(1:6)
Plots.lens!
— Functionlens!([plot,] x, y, inset = (sp_index, bbox(x1, x2, y1, y2)))
Magnify a region of a plot given by x
and y
. sp_index
is the index of the subplot and x1
, x2
, y1
and y2
should be between 0
and 1
.
Plots.mesh3d!
— Methodmesh3d(x,y,z)
mesh3d(x,y,z; connections)
Plot a 3d mesh. On Plotly the triangles can be specified using the connections argument.
Example
x=[0, 1, 2, 0]
y=[0, 0, 1, 2]
z=[0, 2, 0, 1]
i=[0, 0, 0, 1]
j=[1, 2, 3, 2]
k=[2, 3, 1, 3]
plot(x,y,z,seriestype=:mesh3d;connections=(i,j,k))
Plots.mesh3d
— Methodmesh3d(x,y,z)
mesh3d(x,y,z; connections)
Plot a 3d mesh. On Plotly the triangles can be specified using the connections argument.
Example
x=[0, 1, 2, 0]
y=[0, 0, 1, 2]
z=[0, 2, 0, 1]
i=[0, 0, 0, 1]
j=[1, 2, 3, 2]
k=[2, 3, 1, 3]
plot(x,y,z,seriestype=:mesh3d;connections=(i,j,k))
Plots.ohlc!
— Methodohlc(x,y::Vector{OHLC})
ohlc!(x,y::Vector{OHLC})
Make open-high-low-close plot. Each entry of y is represented by a vertical segment extending from the low value to the high value, with short horizontal segments on the left and right indicating the open and close values, respectively.
Example
julia> meanprices = cumsum(randn(100))
julia> y = OHLC[(p+rand(),p+1,p-1,p+rand()) for p in meanprices]
julia> ohlc(y)
Plots.ohlc
— Methodohlc(x,y::Vector{OHLC})
ohlc!(x,y::Vector{OHLC})
Make open-high-low-close plot. Each entry of y is represented by a vertical segment extending from the low value to the high value, with short horizontal segments on the left and right indicating the open and close values, respectively.
Example
julia> meanprices = cumsum(randn(100))
julia> y = OHLC[(p+rand(),p+1,p-1,p+rand()) for p in meanprices]
julia> ohlc(y)
Plots.path3d!
— Methodpath3d(x,y,z)
path3d!(x,y,z)
Plot a 3D path from (x[1],y[1],z[1])
to (x[2],y[2],z[2])
, ..., to (x[end],y[end],z[end])
.
Example
julia> path3d([0,1,2,3],[0,1,4,9],[0,1,8,27])
Plots.path3d
— Methodpath3d(x,y,z)
path3d!(x,y,z)
Plot a 3D path from (x[1],y[1],z[1])
to (x[2],y[2],z[2])
, ..., to (x[end],y[end],z[end])
.
Example
julia> path3d([0,1,2,3],[0,1,4,9],[0,1,8,27])
Plots.pie!
— Methodpie(x, y)
Plot a pie diagram.
Example
x = ["Nerds","Hackers","Scientists"]
y = [0.4,0.35,0.25]
pie(x, y, title="The Julia Community")
Plots.pie
— Methodpie(x, y)
Plot a pie diagram.
Example
x = ["Nerds","Hackers","Scientists"]
y = [0.4,0.35,0.25]
pie(x, y, title="The Julia Community")
Plots.plot3d
— MethodPlot with seriestype :path3d
Plots.quiver!
— Methodquiver(x,y,quiver=(u,v))
quiver!(x,y,quiver=(u,v))
Make a quiver (vector field) plot. The i
th vector extends from (x[i],y[i])
to (x[i] + u[i], y[i] + v[i])
.
Keyword arguments
arrow::Union{Bool, Plots.Arrow}
: Defines arrowheads that should be displayed at the end of path line segments (just before a NaN and the last non-NaN point). Used in quiverplot, streamplot, or similar. Aliases: (:arrows,).
Example
julia> quiver([1,2,3],[3,2,1],quiver=([1,1,1],[1,2,3]))
Plots.quiver
— Methodquiver(x,y,quiver=(u,v))
quiver!(x,y,quiver=(u,v))
Make a quiver (vector field) plot. The i
th vector extends from (x[i],y[i])
to (x[i] + u[i], y[i] + v[i])
.
Keyword arguments
arrow::Union{Bool, Plots.Arrow}
: Defines arrowheads that should be displayed at the end of path line segments (just before a NaN and the last non-NaN point). Used in quiverplot, streamplot, or similar. Aliases: (:arrows,).
Example
julia> quiver([1,2,3],[3,2,1],quiver=([1,1,1],[1,2,3]))
Plots.scatter!
— Methodscatter(x,y)
scatter!(x,y)
Make a scatter plot of y
vs x
.
Keyword arguments
markersize::Union{Real, AbstractVector}
: Size (radius pixels) of the markers. Aliases: (:markersizes, :ms, :msize).markercolor::Union{Integer, Symbol, ColorSchemes.ColorScheme, ColorTypes.Colorant}
: Color of the interior of the marker or shape.:match
will take the value from:seriescolor
. Aliases: (:markercolors, :markercolour, :mc, :mcolor, :mcolour).markershape::Union{Symbol, Plots.Shape, AbstractVector}
: Choose from [:none, :auto, :circle, :rect, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :heptagon, :octagon, :star4, :star6, :star7, :star8, :vline, :hline, :+, :x]. Aliases: (:markershapes, :shape).markeralpha::Real
: The alpha/opacity override for the marker interior.nothing
(the default) means it will take the alpha value of markercolor. Aliases: (:ma, :malpha, :markeralphas, :markeropacity, :mopacity, :mα).
Examples
julia> scatter([1,2,3],[4,5,6],markersize=[3,4,5],markercolor=[:red,:green,:blue])
julia> scatter([(1,4),(2,5),(3,6)])
Plots.scatter
— Methodscatter(x,y)
scatter!(x,y)
Make a scatter plot of y
vs x
.
Keyword arguments
markersize::Union{Real, AbstractVector}
: Size (radius pixels) of the markers. Aliases: (:markersizes, :ms, :msize).markercolor::Union{Integer, Symbol, ColorSchemes.ColorScheme, ColorTypes.Colorant}
: Color of the interior of the marker or shape.:match
will take the value from:seriescolor
. Aliases: (:markercolors, :markercolour, :mc, :mcolor, :mcolour).markershape::Union{Symbol, Plots.Shape, AbstractVector}
: Choose from [:none, :auto, :circle, :rect, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :heptagon, :octagon, :star4, :star6, :star7, :star8, :vline, :hline, :+, :x]. Aliases: (:markershapes, :shape).markeralpha::Real
: The alpha/opacity override for the marker interior.nothing
(the default) means it will take the alpha value of markercolor. Aliases: (:ma, :malpha, :markeralphas, :markeropacity, :mopacity, :mα).
Examples
julia> scatter([1,2,3],[4,5,6],markersize=[3,4,5],markercolor=[:red,:green,:blue])
julia> scatter([(1,4),(2,5),(3,6)])
Plots.scatter3d!
— Methodscatter3d(x,y,z)
scatter3d!(x,y,z)
Make a 3D scatter plot.
Example
julia> scatter3d([0,1,2,3],[0,1,4,9],[0,1,8,27])
Plots.scatter3d
— Methodscatter3d(x,y,z)
scatter3d!(x,y,z)
Make a 3D scatter plot.
Example
julia> scatter3d([0,1,2,3],[0,1,4,9],[0,1,8,27])
Plots.scatterhist!
— Methodscatterhist(x)
scatterhist!(x)
Make a histogram scatter plot (bin counts are represented using points instead of bars). See histogram
.
Plots.scatterhist
— Methodscatterhist(x)
scatterhist!(x)
Make a histogram scatter plot (bin counts are represented using points instead of bars). See histogram
.
Plots.stephist!
— Methodstephist(x)
stephist!(x)
Make a histogram step plot (bin counts are represented using horizontal lines instead of bars). See histogram
.
Plots.stephist
— Methodstephist(x)
stephist!(x)
Make a histogram step plot (bin counts are represented using horizontal lines instead of bars). See histogram
.
Plots.sticks!
— Methodsticks(x,y)
sticks!(x,y)
Draw a stick plot of y
vs x
.
Arguments
fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).markershape::Union{Symbol, Plots.Shape, AbstractVector}
: Choose from [:none, :auto, :circle, :rect, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :heptagon, :octagon, :star4, :star6, :star7, :star8, :vline, :hline, :+, :x]. Aliases: (:markershapes, :shape).
Example
julia> sticks(1:10)
Plots.sticks
— Methodsticks(x,y)
sticks!(x,y)
Draw a stick plot of y
vs x
.
Arguments
fillrange::Union{Real, AbstractVector}
: Fills area between fillrange andy
for line-types, sets the base forbar
,sticks
types, and similar for other types. Aliases: (:fill_between, :fillbetween, :fillranges, :fillrng, :fillto, :frange).markershape::Union{Symbol, Plots.Shape, AbstractVector}
: Choose from [:none, :auto, :circle, :rect, :star5, :diamond, :hexagon, :cross, :xcross, :utriangle, :dtriangle, :rtriangle, :ltriangle, :pentagon, :heptagon, :octagon, :star4, :star6, :star7, :star8, :vline, :hline, :+, :x]. Aliases: (:markershapes, :shape).
Example
julia> sticks(1:10)
Plots.surface!
— Methodsurface(x,y,z)
surface!(x,y,z)
Draw a 3D surface plot.
Example
julia> using LinearAlgebra
julia> x = y = range(-3, stop = 3, length = 100)
julia> surface(x, y, (x, y) -> sinc(norm([x, y])))
Plots.surface
— Methodsurface(x,y,z)
surface!(x,y,z)
Draw a 3D surface plot.
Example
julia> using LinearAlgebra
julia> x = y = range(-3, stop = 3, length = 100)
julia> surface(x, y, (x, y) -> sinc(norm([x, y])))
Plots.title!
— MethodAdd title to an existing plot
Plots.violin!
— Methodviolin(x,y,z)
violin!(x,y,z)
Make a violin plot.
Example
julia> violin(repeat([1,2,3],outer=100),randn(300))
Plots.violin
— Methodviolin(x,y,z)
violin!(x,y,z)
Make a violin plot.
Example
julia> violin(repeat([1,2,3],outer=100),randn(300))
Plots.vline!
— Methodvline(x)
vline!(x)
Draw vertical lines at positions specified by the values in the AbstractVector x
.
Example
julia> vline([-1,0,2])
Plots.vline
— Methodvline(x)
vline!(x)
Draw vertical lines at positions specified by the values in the AbstractVector x
.
Example
julia> vline([-1,0,2])
Plots.vspan!
— Methodvspan(x)
Draw a rectangle between the vertical line at position x[1]
and the vertical line at position x[2]
. If length(x) ≥ 4
, then further rectangles are drawn between x[3]
and x[4]
, x[5]
and x[6]
, and so on. If length(x)
is odd, then the last entry of x
is ignored.
Example
julia> vspan(1:6)
Plots.vspan
— Methodvspan(x)
Draw a rectangle between the vertical line at position x[1]
and the vertical line at position x[2]
. If length(x) ≥ 4
, then further rectangles are drawn between x[3]
and x[4]
, x[5]
and x[6]
, and so on. If length(x)
is odd, then the last entry of x
is ignored.
Example
julia> vspan(1:6)
Plots.wireframe!
— Methodwireframe(x,y,z)
wireframe!(x,y,z)
Draw a 3D wireframe plot.
Example
julia> wireframe(1:10,1:10,randn(10,10))
Plots.wireframe
— Methodwireframe(x,y,z)
wireframe!(x,y,z)
Draw a 3D wireframe plot.
Example
julia> wireframe(1:10,1:10,randn(10,10))
Plots.xaxis!
— MethodSpecify x axis attributes for an existing plot
Plots.xerror!
— Methodxerror(x, y [, z]; xerror = vals)
xerror!(x, y [, z]; xerror = vals)
Create or add a series of xerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.xerror
— Methodxerror(x, y [, z]; xerror = vals)
xerror!(x, y [, z]; xerror = vals)
Create or add a series of xerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.xflip!
— FunctionFlip the current plots' x axis
Plots.xgrid!
— MethodSpecify x grid attributes for an existing plot
Plots.xlabel!
— MethodAdd xlabel to an existing plot
Plots.xlims!
— MethodSet xlims for an existing plot
Plots.xticks!
— MethodSet xticks for an existing plot
Plots.yaxis!
— MethodSpecify y axis attributes for an existing plot
Plots.yerror!
— Methodyerror(x, y [, z]; yerror = vals)
yerror!(x, y [, z]; yerror = vals)
Create or add a series of yerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.yerror
— Methodyerror(x, y [, z]; yerror = vals)
yerror!(x, y [, z]; yerror = vals)
Create or add a series of yerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.yflip!
— FunctionFlip the current plots' y axis
Plots.ygrid!
— MethodSpecify y grid attributes for an existing plot
Plots.ylabel!
— MethodAdd ylabel to an existing plot
Plots.ylims!
— MethodSet ylims for an existing plot
Plots.yticks!
— MethodSet yticks for an existing plot
Plots.zaxis!
— MethodSpecify z axis attributes for an existing plot
Plots.zerror!
— Methodzerror(x, y [, z]; zerror = vals)
zerror!(x, y [, z]; zerror = vals)
Create or add a series of zerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.zerror
— Methodzerror(x, y [, z]; zerror = vals)
zerror!(x, y [, z]; zerror = vals)
Create or add a series of zerrorbars at the positions defined by x
, y
and z
with the lenghts defined in vals
.
Markerstrokecolor will color the whole errorbars if not specified otherwise.
Plots.zflip!
— FunctionFlip the current plots' z axis
Plots.zgrid!
— MethodSpecify z grid attributes for an existing plot
Plots.zlabel!
— MethodAdd zlabel to an existing plot
Plots.zlims!
— MethodSet zlims for an existing plot
Plots.zticks!
— MethodSet zticks for an existing plot
Animations
RecipesBase.animate
— FunctionAnimate from an iterator which returns the plot args each iteration.
Plots.frame
— Functionframe(animation[, plot])
Add a plot (the current plot if not specified) to an existing animation
Plots.gif
— Functiongif(animation[, filename]; fps=20, loop=0, variable_palette=false, verbose=false, show_msg=true)
Creates an animated .gif-file from an Animation
object.
Plots.mov
— Functionmov(animation[, filename]; fps=20, loop=0, verbose=false, show_msg=true)
Creates an .mov-file from an Animation
object.
Plots.mp4
— Functionmp4(animation[, filename]; fps=20, loop=0, verbose=false, show_msg=true)
Creates an .mp4-file from an Animation
object.
Plots.webm
— Functionwebm(animation[, filename]; fps=20, loop=0, verbose=false, show_msg=true)
Creates an .webm-file from an Animation
object.
Plots.@animate
— MacroCollect one frame per for-block iteration and return an Animation
object.
Example:
p = plot(1)
anim = @animate for x=0:0.1:5
push!(p, 1, sin(x))
end
gif(anim)
This macro supports additional parameters, that may be added after the main loop body.
- Add
every n
with positive Integer n, to take only one frame every nth iteration. - Add
when <cond>
where<cond>
is an Expression resulting in a Boolean, to take a frame only when<cond>
returnstrue
. Is incompatible withevery
.
Plots.@gif
— MacroBuilds an Animation
using one frame per loop iteration, then create an animated GIF.
Example:
p = plot(1)
@gif for x=0:0.1:5
push!(p, 1, sin(x))
end
This macro supports additional parameters, that may be added after the main loop body.
- Add
fps=n
with positive Integer n, to specify the desired frames per second. - Add
every n
with positive Integer n, to take only one frame every nth iteration. - Add
when <cond>
where<cond>
is an Expression resulting in a Boolean, to take a frame only when<cond>
returnstrue
. Is incompatible withevery
.
Retriever
Plots.current
— Functioncurrent()
Returns the Plot object for the current plot
Plots.xlims
— Functionxlims([plt])
Returns the x axis limits of the current plot or subplot
Plots.ylims
— Functionylims([plt])
Returns the y axis limits of the current plot or subplot
Plots.zlims
— Functionzlims([plt])
Returns the z axis limits of the current plot or subplot
Plots.backend_object
— Functionbackend_object(plot)
Returns the backend representation of a Plot object. Returns nothing
if the backend does not support this.
Plots.plotattr
— Functionplotattr([attr])
Look up the properties of a Plots attribute, or specify an attribute type. Options are Series, Subplot, Plot, Axis. Call plotattr()
to search for an attribute via fuzzy finding. The information is the same as that given on https://docs.juliaplots.org/latest/attributes/.
Output
Base.Multimedia.display
— Functiondisplay(x)
display(d::AbstractDisplay, x)
display(mime, x)
display(d::AbstractDisplay, mime, x)
Display x
using the topmost applicable display in the display stack, typically using the richest supported multimedia output for x
, with plain-text stdout
output as a fallback. The display(d, x)
variant attempts to display x
on the given display d
only, throwing a MethodError
if d
cannot display objects of this type.
In general, you cannot assume that display
output goes to stdout
(unlike print(x)
or show(x)
). For example, display(x)
may open up a separate window with an image. display(x)
means "show x
in the best way you can for the current output device(s)." If you want REPL-like text output that is guaranteed to go to stdout
, use show(stdout, "text/plain", x)
instead.
There are also two variants with a mime
argument (a MIME type string, such as "image/png"
), which attempt to display x
using the requested MIME type only, throwing a MethodError
if this type is not supported by either the display(s) or by x
. With these variants, one can also supply the "raw" data in the requested MIME type by passing x::AbstractString
(for MIME types with text-based storage, such as text/html or application/postscript) or x::Vector{UInt8}
(for binary MIME types).
To customize how instances of a type are displayed, overload show
rather than display
, as explained in the manual section on custom pretty-printing.
Plots.addExtension
— MethodaddExtension(filepath, extension)
Change filepath extension according to the extension map
Plots.closeall
— MethodClose all open gui windows of the current backend
Plots.eps
— Functioneps([plot,], filename)
Save plot as eps-file.
Plots.gui
— Functiongui([plot])
Display a plot using the backends' gui window
Plots.html
— Functionhtml([plot,], filename)
Save plot as html-file.
Plots.json
— Functionjson([plot,], filename)
Save plot as json-file.
Plots.pdf
— Functionpdf([plot,], filename)
Save plot as pdf-file.
Plots.png
— Functionpng([plot,], filename)
Save plot as png-file.
Plots.ps
— Functionps([plot,], filename)
Save plot as ps-file.
Plots.savefig
— Methodsavefig([plot,] filename)
Save a Plot (the current plot if plot
is not passed) to file. The file type is inferred from the file extension. All backends support png and pdf file types, some also support svg, ps, eps, html and tex.
Plots.svg
— Functionsvg([plot,], filename)
Save plot as svg-file.
Plots.tex
— Functiontex([plot,], filename)
Save plot as tex-file.
Plots.txt
— Functiontxt([plot,], filename)
Save plot as txt-file.