HTML("""<style>
@import url('https://fonts.googleapis.com/css?family=Orbitron|Roboto');
body {background-color: gainsboro;}
a {color: seagreen; font-family: 'Roboto';}
h1 {color: slategray; font-family: 'Orbitron'; text-shadow: 4px 4px 4px #aaa;}
h2, h3 {color: darkslategray; font-family: 'Orbitron'; text-shadow: 4px 4px 4px #aaa;}
h4 {color: slategray; font-family: 'Roboto';}
span {text-shadow: 4px 4px 4px #ddd;}
div.output_prompt, div.output_area pre {color: darkslategray;}
div.input_prompt {color: seagreen;}
div.output_stderr pre {background-color: ghostwhite;}
div.output_stderr {background-color: gainsboro;}
</style>""")
# jupyter notebook --NotebookApp.iopub_data_rate_limit=2147483647
Pkg.resolve()
# Pkg.clone("http://github.com/cormullion/Astro.jl")
using PyCall, PyPlot
using SymPy, LaTeXStrings
using DataFrames, RDatasets
using GR, Plotly
using Interact, Plots
using Winston, Astro
using UnicodePlots
using Distributions, QuantEcon
using GLVisualize, Colors
using GeometryTypes, Reactive
# init_notebook(true)
days = DateTime(2016,1,1,0,0,0):DateTime(2016,12,31,0,0,0);
eq_values=Float64[equation_time(Dates.datetime2julian(day)) for day in days];
head(RDatasets.datasets(), 20)
titanic = dataset("datasets","titanic")
head(titanic, 10)
x = [1.2,3.5,5.8,8.2,10.5,12.2,15.6,17.3,18.9,20.1]
y = [0.8 2.1 4.2 5.7 6.5 7.9 9.6 11.3 15.6 19.9]
x1, y1, z1 = [1,3,5], [0,0,0], [0,0,0]
dx1, dy1, dz1 = [1, 1, 1], [3, 3, 3], [5, 3, 7]
x2 = [2,3,4]
y2 = [1,3,5]
z2 = [[2,1,1], [3,3,8], [4,5,5]]
numbers = rand(10,4)
equation(numbers) = -5 * tan.(numbers) + 10 * tan.(3*numbers + 100);
Θ = linspace(0,6π,200)
writedlm("test.txt", numbers)
numbers = readdlm("test.txt")
vectors = ([-3, 2], [4, 3], [1, 5])
x_array = zeros(2, length(vectors))
y_array = zeros(2, length(vectors));
labels = []
for l = 1:length(vectors)
vector_label = vectors[l]
x_array[2, l] = vector_label[1]
y_array[2, l] = vector_label[2]
labels = [labels; (1.1 * vector_label[1], 1.1 * vector_label[2], "$vector_label")]
end
labels
@vars a b c
p=expand( (a+1)*(a-2)*(a^2-10) )
factor(p)
polyroots(p)
map(N,SymPy.solve(p))
fig1 = PyPlot.figure(figsize=(14,7))
surf(randn(20,20), cmap="bone", alpha=0.4);
bar3D(x1, y1, z1, dx1, dy1, dz1);
fig2 = PyPlot.figure(figsize=(14,7))
contour3D(x2, y2, z2, extend3d=true, stride=1, cmap="bone", alpha=0.5, w=3);
scatter3D(rand(10,10), rand(10,10), rand(10,10), marker="8", c="darkgreen", alpha=0.5);
fig3 = PyPlot.figure(figsize=(14,7))
csd(rand(100,100), rand(100,100), color="darkgreen")
gr()
Plots.plot(p, -4, 4, label="function (a+1) * (a-2) * (a^2-10)", size=(900, 400), w=2)
Plots.plot([sin,cos], -5pi, 5pi, label=["sin","cos"], w=3, size=(900, 400))
Plots.plot(eq_values, size=(900, 400), line=(2,:dash), label="line")
pyplot()
Plots.plot(x_array, y_array, arrow=true, color=:blue, size=(700, 500),
legend=:none, xlims=(-5, 5), ylims=(-1, 7), title="Vector Addition",
annotations = labels, xticks=-5:1:5, yticks=-1:1:7)
vline!([0], color=:black)
hline!([0], color=:black)
Plots.plot(equation(numbers), xlims=(1, 10), ylims=(-450, 150), size=(900, 400))
z = rand(20,3)
Plots.plot(z,xaxis=("XLABEL",(-5,30),0:2:20,:flip),yaxis=("YLABEL",:log10),
background_color=RGB(0.4,0.4,0.4),
leg=false,title="TITLE",size=(1250, 450))
hline!(mean(z,1) + rand(1,3),line=(2,:dash,0.7,[:lightblue :royalblue :blue]))
vline!([5,10,15], line=(2, :dash))
Plots.scatter(rand(100), rand(100), leg=false,
ms=20*rand(100), alpha=0.5, c=:darkgreen,
xlims=(-0.1, 1.1), ylims=(-0.1, 1.1), size=(900, 400))
plotly()
Plots.plot(Θ,abs.(0.1 * randn(200) + sin.(3Θ)),proj=:polar, size=(900, 400), label="sin")
Plots.plot!(Θ,abs.(0.1 * randn(200) + cos.(3Θ)),proj=:polar, label="cos")
Plots.plot(x, numbers, title="Title", label=["First Line" "Second Line" "Third Line" "Fourth Line"], size=(900, 400))
start = Date(2015, 6, 21)
x4 = map(d -> start + Base.Dates.Day(d), 1:120)
y4 = 15 + randn(120) * 4
Plots.plot(x4, y4, title="A typical British Summer",size=(900, 400), label="temperature")
unicodeplots()
Plots.plot(Vector[randn(100),randn(100) * 100],axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT")
Plots.histogram(randn(1000),nbins=50)
mplt=lineplot([-1, 2, 3, 7], [1, 2, 9, 4], title = "Unicode Plot", name = "first line", canvas = AsciiCanvas,
border = :ascii, color=:blue, width = 90)
lineplot!(mplt, [0, 4, 8, 10], [10, 1, 10, 1], color = :yellow, name = "second line")
mplt2=densityplot(randn(1000), randn(1000), color = :blue, width = 90)
densityplot!(mplt2, randn(1000) + 1, randn(1000) + 2, color = :red)
# Winston
Winston.plot(x, y, "g*")
pyplot()
p1 = Plots.plot([sin,cos], zeros(0), leg=false, size=(900, 400));
anim1 = Animation();
for t = linspace(0,20π,200)
push!(p1,t,Float64[sin(t),cos(t)])
frame(anim1)
end;
gif(anim1, "anim1.gif", fps=15)
n = 1500
dt = 0.02
σ, ρ, β = 10., 28., 8/3
x, y, z = 1., 1., 1.
# initialize a 3D plot with 1 empty series
p2 = path3d(1, xlim=(-25,25), ylim=(-25,25), zlim=(0,50),
xlab = "x", ylab = "y", zlab = "z", label="line",
title = "Lorenz Attractor", marker = 1, size=(900, 700))
# build an animated gif, saving every 10th frame
@gif for i=1:n
dx = σ*(y - x) ; x += dt * dx
dy = x*(ρ - z) - y ; y += dt * dy
dz = x*y - β*z ; z += dt * dz
push!(p2, x, y, z)
end every 10
togglebutton(label="push"; value=true)
dropdown(["one", "two", "three"])
P1 = [0.33 0.33 0.34; 0.1 0.8 0.1; 0.33 0.33 0.34]; MC1 = MarkovChain(P1)
X1 = simulate(MC1, 100000); mean(X1 .== 1)