In [3]:
using Plots
using Colors
gr()


Out[3]:
Plots.GRBackend()

In [4]:
base03=parse(Colorant,"#002b36");
base02=parse(Colorant,"#073642");
base01=parse(Colorant,"#586e75");
base00=parse(Colorant,"#657b83");
base0=parse(Colorant,"#839496");
base1=parse(Colorant,"#839496");
base2=parse(Colorant,"#eee8d5");
base3=parse(Colorant,"#fdf6e3");

yellow=parse(Colorant,"#b58900");
orange=parse(Colorant,"#cb4b16");
red=parse(Colorant,"#dc322f");
magenta=parse(Colorant,"#d33682");
violet=parse(Colorant,"#6c71c4");
blue=parse(Colorant,"#268bd2");
cyan=parse(Colorant,"#3aa198");
green=parse(Colorant,"#859900");

display([base03, base02, base01,base00,base0,base1,base2,base3])
display([yellow,orange,red,magenta,violet,blue,cyan,magenta])



In [5]:
x=collect(0:.1:4π);
y1=sin.(x);
y2=cos.(x);
y3=sin.(2*x);
y4=cos.(2*x);
y5=sin.(x/2);

In [6]:
plot(x,y1,label="leg label")
plot!(title="Title",
    xlabel="x label",
    ylabel="y label")


Out[6]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 Title x label y label leg label

In [7]:
plot(x,y1,legend=false)


Out[7]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5

Annotations


In [8]:
plot(x,y1,
    annotation=(x[10],y1[10],"Hi!"))


Out[8]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1 Hi!

In [9]:
plot(x,y1)
annotate!(x[10],y1[10],"Hello World!")


Out[9]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1 Hello World!

In [10]:
plot(x,y1)
annotate!(x[10],y1[10],text("Hello World!",:left))

annotate!(x[60],y1[60],text("Right and Red",:right,magenta,45.))

annotate!(x[70],y1[70],text("Right and Red",font(:right,magenta,45.)))


Out[10]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1 Hello World! Right and Red Right and Red

In [14]:
f=font(:center,magenta,45.)

println(f,"\t",typeof(f))

plot(x,y1)
annotate!(10*rand(),rand(),text("Point 1",f))

annotate!(10*rand(),rand(),text("Point 2",f))

annotate!(10*rand(),rand(),text("Point 3",f))


Plots.Font("sans-serif", 14, :hcenter, :vcenter, 45.0, RGB{N0f8}(0.827,0.212,0.51))	Plots.Font
Out[14]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1 Point 1 Point 2 Point 3

Axes


In [31]:
plot(x,y1,
    xticks=[0,π,2π,3π,4π],
    yticks=[-1,-.5,0,.5,1]    )


Out[31]:
0.0000000 3.1415927 6.2831853 9.4247780 -0.5 0.0 0.5 y1

Backend Warning

gr did not support formatter, so I'm switching to pyplot at this point.


In [21]:
pyplot()
plot(x,y1,formatter=:scientific)


Out[21]:

In [28]:
function mylabel(num::Real)
    if isapprox(num,π)
        return "π"
    elseif isapprox(num,0)
        return "0"
    end
    
    num2=num/π
    
    for ii in 1:10
        if isapprox(num2,ii)
            return "$ii π"
        elseif isapprox(num,-ii)
            return "-$ii π"
        end
    end
        
    return "$num"
end


Out[28]:
mylabel (generic function with 1 method)

In [35]:
pyplot()
plot(x,y1,
    xticks=[0,π,2π,3π,4π],
    formatter=mylabel)


Out[35]:

In [37]:
gr()
plot(x,y1,
    ylims=[-.5,.5])


Out[37]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.50 -0.25 0.00 0.25 0.50 y1

In [36]:
gr()
plot(x,y1,
    rotation=45)


Out[36]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1

In [51]:
plot(factorial.(1:20),
    yscale=:log10)


Out[51]:
5 10 15 20 10 0 10 5 10 10 10 15 y1

In [53]:
plot(x,y1,
    xflip=true)


Out[53]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1

Legend

Some possible location values

:none
:best
:right
:left
:top
:bottom
:inside
:legend
:topright
:topleft
:bottomleft
:bottomright`

In [55]:
plot(x,y1,
    legend=:bottomright)


Out[55]:
0.0 2.5 5.0 7.5 10.0 12.5 -0.5 0.0 0.5 y1

In [ ]: