using PGFPlots x = [1,2,3] y = [2,4,1] plot(x, y) Axis(Plots.Linear(x, y)) pushPGFPlotsOptions("scale=1.5") a = Axis(Plots.Linear(x, y, legendentry="My Plot"), xlabel="X", ylabel="Y", title="My Title") a.ylabelStyle = "rotate = -90" a.legendStyle = "{at={(1.05,1.0)},anchor=north west}" a popPGFPlotsOptions(); resetPGFPlotsOptions(); a = Axis(Plots.Linear(x, y), width="3cm", height="3cm") Axis(Plots.Linear(x, y), xlabel=L"$X$", ylabel=L"$Y$", title=L"$\int_0^\infty e^{\pi x}dx$") Axis([ Plots.Linear(sin, (0,10), legendentry=L"$\sin(x)$"), Plots.Linear(x->sqrt(2*x), (0,10), legendentry=L"$\sqrt{2x}$") ]) Axis([ Plots.Linear(sin, (0,10), legendentry=L"$\sin(x)$"), Plots.Linear(x->sqrt(2*x), (0,10), legendentry=L"$\sqrt{2x}$") ], legendPos="north west") Plots.Linear(1:10, sin(1:10), style="ycomb") Plots.Linear(abs(sin(1:10)), 1:10, style="xcomb") Plots.Linear(1:10, sin(1:10), style="smooth") Plots.Linear(1:10, sin(1:10), style="const plot") Plots.Linear(1:10, sin(1:10), style="ybar") Plots.Linear(1:10, sin(1:10), style="ybar,fill=green", mark="none") p = Plots.Linear(0.01:0.01:1, 10.^(0.01:0.01:1), mark="none") Axis(p, ymode="log") p = Plots.Linear(0:10, (0:10).^2, style="red, fill=blue, fill opacity=0.3", mark="none") p = Plots.Linear(0:10, 2*(0:10)) a = Axis(p, axisEqual=true, xmin=0, xmax=10) # note xmin and xmax are disregarded... p = Plots.Linear(0:10, 2*(0:10)) a = Axis(p, axisEqualImage=true) Plots.Linear(0:10, 2*(0:10), markSize=10) Plots.Linear(0:10, 2*(0:10), onlyMarks=true) x = [1,2,3] y = [2,4,1] plot(x, y, errorBars = ErrorBars(y=[1, 0.3, 0.5])) plot(x, y, errorBars = ErrorBars(yplus=[1, 0.3, 0.5], yminus=[0.5, 0.1, 0.1])) plot(x, y, errorBars = ErrorBars(y=[1, 0.3, 0.5], x=[0.1, 0.1, 0.05])) plot(x, y, errorBars = ErrorBars(y=[1, 0.3, 0.5], style="red,very thick")) plot(x, y, errorBars = ErrorBars(y=[1, 0.3, 0.5], mark="diamond")) plot(x, y, style="red", errorBars = ErrorBars(y=[1, 0.3, 0.5], style="black,very thick", mark="diamond")) x = 1:10 y = 2x Plots.Scatter(x, y) z = 3x Plots.Scatter(x, y, z) p = Plots.Scatter(x, y, z) a = Axis(p, colorbar=true) z = ["a", "a", "a", "b", "b", "b", "b", "c", "c", "c"] sc = "{a={mark=square,blue},b={mark=triangle,red},c={mark=o,black}}" Plots.Scatter(x, y, z, scatterClasses=sc) Plots.Scatter(x, y, z, scatterClasses=sc, legendentry=["A", "B", "C"]) Axis(Plots.Scatter(x, y, z, scatterClasses=sc, legendentry=["A", "B", "C"]), style="legend columns=-1", legendPos="north west") d = randn(100) Axis(Plots.Histogram(d, bins=10), ymin=0) Axis(Plots.Histogram(d, bins=20, cumulative=true, density=true), ymin=0) Axis(Plots.Histogram(d, bins=10, style="red,fill=red!10"), ymin=0, ylabel="Counts") Axis(Plots.Histogram(d, discretization=:auto), ymin=0) discretizations = [:default, # use PGFPlots for small data sizes and :auto for large :pgfplots, # use the PGFPlots histogram function (uses nbins, which defaults to 10) :specified, # use Discretizers.jl but with the specified number of bins (which defaults to 10) :auto, # max between :fd and :sturges. Good all-round performance :fd, # Freedman Diaconis Estimator, robust :sturges, # R's default method, only good for near-Gaussian data :sqrt, # used by Excel and others for its simplicity and speed :doane, # improves Sturges’ for non-normal datasets. :scott, # less robust estimator that that takes into account data variability and data size. ] srand(0) data = [randn(500).*1.8 .+ -5; randn(2000).*0.8 .+ -4; randn(500).*0.3 .+ -1; randn(1000).*0.8 .+ 2; randn(500).*1.5 .+ 4; ] data = filter!(x->-15.0 <= x <= 15.0, data) g = GroupPlot(3, 3, groupStyle = "horizontal sep = 1.75cm, vertical sep = 1.5cm") for discretization in discretizations push!(g, Axis(Plots.Histogram(data, discretization=discretization), ymin=0, title=string(discretization))) end g f = (x,y)->x*exp(-x^2-y^2) Plots.Image(f, (-2,2), (-2,2)) Plots.Image(f, (-2,2), (-2,2), zmin=-1, zmax=1) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Gray(invert = true)) Plots.Image(f, (-2,2), (-2,2), colorbar = false) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Distinguishable(3)) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Distinguishable(4)) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Distinguishable(4, invert=true)) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Named("Blues")) using Colors cm = colormap("RdBu") Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.RGBArray(cm)) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Named("Jet")) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Brew("Set1", 3)) Plots.Image(f, (-2,2), (-2,2), colormap = ColorMaps.Brew("Set1", 3, invert=true)) p = Plots.Patch2D([0 1 2 1 2 3 2 3 4; # x 0 1 0 1 0 1 0 1 0]) # y p = Plots.Patch2D([0 1 2 1 2 3 2 3 4; # x 0 1 0 1 0 1 0 1 0; # y 0.2 0 1 0 1 0 1 0 0.5]) # color p = Plots.Patch2D([0 1 2 1 2 3 2 3 4; # x 0 1 0 1 0 1 0 1 0; # y 0.2 0 1 0 1 0 1 0 0.5], # color shader = "interp") p = Plots.Patch2D([0 1 2 1 2 3 2 3 4; # x 0 1 0 1 0 1 0 1 0; # y 0.2 0 1 0 -1 0 0.5 1 0.5], # color shader = "interp") p = Plots.Patch2D([0 1 1 0 1 2 2 1 1 2 2 1; # x 0 0 1 1 0 0 1 1 1 1 2 2; # y 0.2 0 1 1 0 -1 0 1 0.5 1 0.5 0], # color shader = "interp", patch_type="rectangle") x = randn(10000)*2 + 1 y = randn(10000) - 2 Plots.Histogram2(x, y) Plots.Histogram2(x, y, xmin=-3, xmax=3, ymin=-3, ymax=3, zmin=-1, colormap=ColorMaps.Named("Jet")) Plots.Histogram2(x, y, xmin=-3, xmax=3, ymin=-3, ymax=3, zmin=5, zmax=15, colormap=ColorMaps.Named("Jet")) Axis(Plots.Histogram2(x, y, density=true, xmin=-3, xmax=3, ymin=-3, ymax=3), axisEqualImage=true) Plots.Histogram2(x, y, density=true) x = randn(10000)+1.0 y = randn(10000) edges_x = [-3.0,-1.0,0.0,0.5,0.75,1.0,1.25,1.5,2.0,3.0] edges_y = linspace(-3.0,3.0,11) p = Plots.Histogram2(x, y, edges_x, edges_y, density=true, style="colormap/blackwhite") ax = Axis(p, enlargelimits=0) Plots.Contour(f, (-2,2), (-2,2)) Plots.Contour(f, (-2,2), (-2,2), levels=-0.4:0.1:4) Plots.Contour(f, (-2,2), (-2,2), number=20) Plots.Contour(f, (-2,2), (-2,2), style="very thick") x = linspace(-2,2) y = linspace(-2,2) A = Float64[f(xi, yi) for xi in x, yi in y] Plots.Contour(A, x, y) Plots.Contour(randn(11,11), 0:10, 0:10) h(x,y) = [exp(-x^2-y^2)*(1-2*x^2), exp(-x^2-y^2)*(-2*x*y)] Plots.Quiver(h,(-2,2),(-2,2)) h2(x,y) = [exp(-x^2-y^2)*(1-2*x^2), exp(-x^2-y^2)*(-2*x*y)] Plots.Quiver(h2,(-2,2),(-2,2), style="-stealth'") Plots.Quiver(h,(-2,2),(-2,2), normalize=false) # generate 1000 samples d = randn(1000) # try out histograms with a variety of different number of bins bins = [3 10 50 1000] g = GroupPlot(2,2) # create a 2 x 2 group plot for i = 1:length(bins) push!(g, Axis(Plots.Histogram(d, bins=bins[i]), ymin=0)) end g g = GroupPlot(2, 2, groupStyle = "horizontal sep = 3cm") # create a 2 x 2 group plot for i = 1:length(bins) push!(g, Axis(Plots.Histogram(d, bins=bins[i]), ymin=0)) end g #Create the first axis and add to it two lines a1 = PGFPlots.Axis(style="width=10cm, height=10cm, grid=both"); push!(a1, PGFPlots.Linear([1,2],[10, 10], style="blue")) push!(a1, PGFPlots.Linear([1,2],[10, 3], style="red")) #Create another axis with smaller width. #xshift and yshift are used to position the axis. a2 = PGFPlots.Axis(style="width=4cm, xshift=1cm, yshift=1cm", title="xy reflection"); push!(a2, PGFPlots.Linear([10, 10], [1,2], style="no marks, blue, thick")) push!(a2, PGFPlots.Linear([10, 3] , [1,2], style="no marks, red, thick")); #Group the two axes together as a list [a1, a2] Axis([ Plots.Image(f, (-2,2), (-2,2)), Plots.Node(L"\sqrt{2}",1,0) ]) Axis([ Plots.Image(f, (-2,2), (-2,2)), Plots.Node(L"\sqrt{2}",-1,0,style="yellow"), Plots.Node("Hi there!",1,0,style="right") ]) Axis([ Plots.Image(f, (-2,2), (-2,2)), Plots.Node(L"\sqrt{2}",0.9,0.9,axis="axis description cs") ]) p1 = Plots.Circle(5,5,5) p2 = Plots.Ellipse(5,5,3,5) a = Axis([p1,p2], xmin=0,ymin=0,xmax=10,ymax=10) a = Axis([p1,p2], xmin=0,ymin=0,xmax=10,ymax=10, hideAxis=true) t = rad2deg(linspace(0,5pi,60)) x = sind(t) y = cosd(t) z = 2t/(5pi) p = Plots.Linear3(x, y, z, mark="none") Axis(p, xlabel="x", ylabel="y", zlabel="z") Axis(p, view="{60}{30}", xlabel="x", ylabel="y", zlabel="z") using TikzPictures TikzPictures.tikzDeleteIntermediate(false) angles = [0,90,180,270] radii = ones(4) p = Plots.Linear(angles, radii) pa = PolarAxis(p) define_color("myrgbcolor1", [1,0.2,0.3]) Plots.Linear(x, y, style="myrgbcolor1") define_color("mycmykcolor1", [1,0.2,0.3,0]) Plots.Linear(x, y, style="mycmykcolor1") define_color("myRGBcolor", [82,227,246]) Plots.Linear(x, y, style="myRGBcolor") define_color("mylightgray", 0.9) Plots.Linear(x, y, style="mylightgray") define_color("myhtmlcolor", 0xff7f00) Plots.Linear(x, y, style="myhtmlcolor") define_color("mycolor", HSV(300, 0.2, 0.9)) Plots.Linear(x, y, style="mycolor, very thick") using DataFrames df = DataFrame(x=[1,2,3], y=[2,4,1], z=[0.0,0.5,1.0]) df_big = DataFrame(x=randn(1000), y=randn(1000)) df_quiver = DataFrame(x=[0,0,1,1], y=[0,1,0,1], u=[0.25,0.25,-0.25,-0.25], v=[0.25,-0.25,0.25,-0.25]) g = GroupPlot(3, 3, groupStyle = "horizontal sep = 1.75cm, vertical sep = 1.5cm") push!(g, Axis(Plots.Linear(df), title="Linear")) push!(g, Axis(Plots.Linear(df, x=:y, y=:z, style="red", mark="none"), title="Linear with Options")) push!(g, Axis(Plots.Linear3(df), title="Linear3")) push!(g, Axis(Plots.Scatter(df), title="Scatter")) push!(g, Axis(Plots.Histogram(df_big), title="Histogram")) push!(g, Axis(Plots.Quiver(df_quiver), title="Quiver")) push!(g, Axis(Plots.Histogram2(df_big), title="Histogram2 - Image")) push!(g, Axis(Plots.Histogram2(df_big, Float64[-3,-1,1,3], Float64[-3,-2,-1,0,1,2,3], style="colormap/blackwhite"), enlargelimits=0, title="Histogram2 = Patch2D")) g df = DataFrame(position=[0.0,0.5,1.5,4.0], time=[0.0,1.0,2.0,3.0]) Axis(Plots.Linear(df, x=:time, y=:position), xlabel="time [s]", ylabel="position [m]") Axis([ Plots.Linear(x, y, style="mycolor, very thick"), Plots.Command("\\legend{Test}") ]) pushPGFPlotsPreamble("\\usepackage{cmbright}") Plots.Linear(x, y, legendentry = "Test") popPGFPlotsPreamble() Plots.Linear(x, y, legendentry = "Test") p = Plots.Histogram(rand(10)) save("myfile.tex", p) save("myfile.pdf", p) save("myfile.svg", p) p = Plots.Histogram(rand(10)) save("myfile.tex", p, include_preamble=false) using Reel Reel.set_output_type("gif") # may be necessary for use in IJulia frames = Frames(MIME("image/svg+xml"), fps=10) for frame in 1:10 t = frame/5 ax = Axis(Plots.Linear(x -> sin(x+t*π), (0,6)), xlabel="x", ylabel="y") push!(frames, ax) end frames