In [ ]:
using Plots, TestImages
pyplot(ratio=1, size=(350,300))
RecipesBase.debug()
img = testimage("lena_color_256")
In [ ]:
plot(img)
In [ ]:
using Plots
x=1:10
y=["y$i" for i=1:5]
z=rand(["A","B","C"], 5, 10)
heatmap(x,y,z)
In [ ]:
using Plots; pyplot(size=(300,200))
x = y = linspace(-5,5,20)
f(x,y) = sin(x)+cos(y)
p1 = wireframe(x,y,f)
In [ ]:
p2 = surface(x,y,f)
In [ ]:
p3 = contour(x,y,f,fill=true)
In [ ]:
l = @layout [a b;c{0.1h}]
p = plot(p1,p2,p3, layout=l, size=(700,500), cbar=false)
In [ ]:
plot(p, plot(rand(100)),size=(700,400))
In [ ]:
p1
In [ ]:
using Plots
pyplot(fmt=:png)
@userplot type StackHist
vecs::Tuple
StackHist(vecs::AVec...) = new(vecs)
end
@recipe function f(sh::StackHist)
# get one set of edges to bin with
alldata = vcat(sh.vecs...)
edges,_ = hist(alldata, get(d,:bins,default(:bins)))
# common attributes
fillalpha --> 0.3 # optional override
seriestype := :bar # forced override
# for each vector, we create a series... bar chart starting at the
# last total height of the last series
lastcnts = 0
for v in sh.vecs
@series begin
# force the fillrange to the last heights
fillrange := lastcnts
# get the new hist counts, then add to total
cnts = hist(v, edges)[2]
lastcnts = lastcnts + cnts
# compute bar widths
dffs = diff(edges)
bar_width := 0.8dffs
# return centers and heights... this is the input data to the series
centers = edges[1:end-1] + dffs
centers, cnts
end
end
end
In [ ]:
stackhist(rand(100), rand(200), randn(100), bins=20)
In [ ]:
bar(rand(10),fillrange=0)
In [ ]:
using Plots
pyplot(size=(400,200))
x=1:10
y=["Y_$i" for i in 1:5]
z=rand(["Hello","World","!"],5,10)
heatmap(x,y,z, y_discrete_values = vcat(y, "unused1", "unused2"))
In [ ]:
heatmap(x,y,z, z_discrete_values = ["Hello","World","!"])
In [ ]:
using Plots; gr()
set_theme(:ggplot2)
plot(rand(10))
In [ ]:
using Plots
y = rand(100,4)
y[:,3] *= 10
x = rand(100,4)
x[:,2] *= 3
plot(x, y, layout=GridLayout(2,2,widths=[0.8,0.2],heights=[0.2,0.8]), link=:both,
xticks=[nothing nothing :auto :auto], yticks=[:auto nothing])
In [ ]:
Plots.DD(current().subplots[1].attr[:xaxis].d)
In [ ]:
In [ ]:
using Plots; pyplot
p = plot(Any[rand(10), 10rand(10), 10rand(100), rand(100)], layout=4)
In [ ]:
p.subplots[2].attr[:yaxis] = p.subplots[1].attr[:yaxis]
In [ ]:
p
In [ ]:
push!(p,1,10)
p
In [ ]:
p.subplots[1].attr[:yaxis][:extrema]
In [ ]:
p
In [ ]:
scatter!(256rand(100), 256rand(100), m=(10,0.3,:blue))
In [ ]:
n,m = size(img)
plot(Array(img)[1:4:n, 1:4:m])
In [ ]:
display(current())
In [ ]:
typeof(img[1:8:n, 1:8:m])
In [ ]:
z = reshape(1:25,5,5)
In [ ]:
heatmap(z)
In [ ]:
z[1:2:5,1:2:5]
In [ ]:
surface(z)
In [ ]:
using Images
typeof(data(img))
In [ ]:
raw(img)
In [ ]:
import PyPlot
PyPlot.imshow(raw(img)')
In [ ]:
rd = permutedims(raw(img),[2,1])
In [ ]:
PyPlot.imshow(rd, cmap=:gray)
In [ ]:
In [ ]:
using PlotRecipes, Plots
plotlyjs()
n = 10
G = PlotRecipes.MyGraph(ones(n), Symmetric(Float64[i==j||rand()<0.7 ? 0 : 1 for i=1:n,j=1:n]))
plot(G, arrow=0.6, m=20)
In [ ]:
using Plots
plotlyjs()
y = Float64[rand()<0.2 ? NaN : 10rand() for i=1:30]
plot(y, arrow=5)
In [ ]:
using Plots; pgfplots()
plot(rand(10), ratio=1)
In [ ]:
using PGFPlots
Plots.Linear(1:10, sin(1:10), style="""
ybar,
fill = green,
mark = +,
,
mark size=10
""")
In [ ]:
using Plots, Distributions
@recipe function f(n::Normal)
w = 4n.σ
x = linspace(n.μ-w, n.μ+w, 100)
fillrange --> 0
x, _->pdf(n,_)
end
m = 2
s = 2
with(alpha=0.8,xlim=(-5,5),fg=RGBA(0,0,0,0)) do
plot(Normal(), c=:green)
plot!(Normal(-m,s), c=:red)
plot!(Normal(m,s), c=:purple)
end
In [ ]:
using Plots; pyplot()
x,y = randn(100),randn(100)
histogram2d(x,y)
In [ ]:
histogram2d(x,y, c=ColorGradient(:blues, log2(1:0.1:2).^5))
In [ ]: