using PlotlyJS trace1 = scatter(y=rand(10), marker_color="red", marker_line_width=2.0) trace2 = contour(x=1:5, y=1:10, z=randn(5, 10)) trace3 = bar(x=1:10, y=rand(1:10, 10), name="mybar") print(json(trace1, 2)) layout = Layout(xaxis=attr(range=[0, 10], title="assets"), yaxis_title="consumption", title="??") print(json(layout, 2)) plot(trace1, layout) # layout optional plot(trace2) plot([trace1, trace3], layout) methods(plot) x = linspace(-5, 5, 50) y1 = sin(x) y2 = cos(x) plot(x, y1) # x optional and set attributes with keywords plot(y1, marker_color="red", mode="markers") # columns become traces plot(x, [y1 y2], kind="bar") # can pass layout plot(x, [y1 y2], Layout(title="My sinusoids")) # can plot functions plot([sin, _ -> cos(_)], -6, 6, Layout(title="My sinusoids"), marker_symbol="square", mode="markers+lines") rand_plot(n) = plot(scatter(x=1:n, y=randn(n))) p1, p2, p3, p4 = [rand_plot(i) for i in [10, 20, 30, 40]] [p1 p2] [p1 p2 p3] [p1, p2] p = [p1 p2; p3 p4] import Plots # import, not using to avoid clash Plots.plotlyjs() npts = 125 d = randn(npts) x = linspace(0, 2*π, npts) y = copy(x) sinx = sin(x) cosx = cos(x) z = cos(x') .+ sin(y); Plots.plot(x, sinx, leg=false, color=:red, style=:dash) Plots.contour(x, y, z, fill=true) Plots.scatter!([2.5], [2.5], color=:black, ms=3, leg=false) Plots.annotate!([(2.5, 2.5, Plots.text("This is 2.5, 2.5", 12, :white, :left))]) Plots.plot(sin,(x->sin(2x)), 0, 2π, line=4, leg=false, fill=(0, :orange)) x = 1:0.3:20 y = x f(x,y) = sin(x) + cos(y) Plots.contour(x, y, f, fill=true) # Filling in fields ggplot = let axis = attr(showgrid=true, gridcolor="white", linewidth=1.0, linecolor="white", titlefont_color="#555555", titlefont_size=14, ticks="outside", tickcolor="#555555" ) layout = Layout(plot_bgcolor="#E5E5E5", paper_bgcolor="white", font_size=10, xaxis=axis, yaxis=axis, titlefont_size=14) gta = attr(marker_line_width=0.5, marker_line_color="#348ABD") colors = ["#E24A33", "#348ABD", "#988ED5", "#777777", "#FBC15E", "#8EBA42", "#FFB5B8"] Style(layout=layout, color_cycle=colors, global_trace=gta) end # ggplot style, but scatter traces have square markers square_ggplot = Style(ggplot, trace=Dict(:scatter => attr(marker_symbol="square"))) # composing big_title = Style(layout=Layout(titlefont_size=20)) big_ggplot = Style(ggplot, big_title) use_style!(ggplot) plot([sin, cos],-6, 6, Layout(title="My title")) # notice title for this plot is bigger p= plot([sin, cos],-6, 6, Layout(title="My title"), style=big_ggplot) savefig(p, "/Users/sglyon/Desktop/my_ggplot.pdf")