1- #A Julia interface to the plot.ly API
1+ # A Julia interface to the plot.ly API
2+
3+ [ ![ Build Status] ( https://travis-ci.org/snotskie/Plotly.jl.png )] ( https://travis-ci.org/snotskie/Plotly.jl )
24
35Forked from [ astrieanna/Plotly.jl] ( https://github.com/astrieanna/Plotly.jl )
46
@@ -8,62 +10,152 @@ README quickly to get started. Alternately, checkout out the pretty Julia docs a
810
911Given that you have Julia v0.2.1,
1012
11- Pkg.clone("https://github.com/plotly/Plotly.jl")
13+ ``` julia
14+ Pkg. clone (" https://github.com/plotly/Plotly.jl" )
15+ ```
1216
1317## Usage
14-
15- julia> using Plotly
16- INFO: Cloning Plotly from https://github.com/plotly/Plotly.jl
17- INFO: Computing changes...
18- INFO: No packages to install, update or remove.
19-
18+ ``` julia
19+ julia> using Plotly
20+ INFO: Cloning Plotly from https: // github. com/ plotly/ Plotly. jl
21+ INFO: Computing changes...
22+ INFO: No packages to install, update or remove.
23+ ```
2024
2125You'll need to create a plot.ly account and find out your API key before you'll be able to use this package.
26+
2227## New user signup
23- julia> Plotly.signup("username","email")
24- Success! Check your email to activate account.
25-
28+ ``` julia
29+ julia> Plotly. signup (" username" ," email" )
30+ Success! Check your email to activate account.
31+ ```
32+
2633## Signin
27- julia> Plotly.signin("username","your api key")
28- PlotlyAccount("username","your api key")
34+ ``` julia
35+ julia> Plotly. signin (" username" ," your api key" )
36+ PlotlyAccount (" username" ," your api key" )
37+ ```
2938
3039## Plot && Open in browser
31- julia> Plotly.openurl(Plotly.plot(["z"=>rand(6,6)],["style"=>["type"=>"heatmap"]]))
32- START /bin/firefox "https://plot.ly/~astrieanna/0"
33-
40+ ``` julia
41+ julia> Plotly. openurl (Plotly. plot ([" z" => rand (6 ,6 )],[" style" => [" type" => " heatmap" ]]))
42+ START / bin/ firefox " https://plot.ly/~astrieanna/0"
43+ ```
44+
3445That last line is what the REPL prints out,
3546as a Firefox tab opens with the plot.
3647You can also just call ` plot ` by itself, and you'll get a String that's the url of your chart.
3748
3849## Style and Layout
39- julia> Plotly.style(["line"=>["color"=>"rgb(255,0,0)","width"=>10]])
40-
41- julia> Plotly.layout(["layout"=>["title"=>"Time Wasted"]])
42-
43- ## Plot Functions and Polynomials
44- julia> Plotly.plot(abs)
45- julia> Plotly.plot([sqrt, log], ["left"=>10, "right"=>20, "step"=>0.1])
50+ ``` julia
51+ julia> Plotly. style ([" line" => [" color" => " rgb(255,0,0)" ," width" => 10 ]])
52+ julia> Plotly. layout ([" layout" => [" title" => " Time Wasted" ]])
53+ ```
54+
55+ # Quick Plotting
56+ ## Functions and Polynomials
57+ ``` julia
58+ julia> Plotly. plot (abs)
59+ julia> Plotly. plot ([sqrt, log], [" left" => 10 , " right" => 20 , " step" => 0.1 ])
60+ julia> Plotly. plot () do x
61+ savings = 3000
62+ income = x* 1000
63+ expenses = x* 800
64+ return savings+ income- expenses
65+ end
66+ ```
4667
4768You can now plot functions directly.
4869The first line shows how to plot the absolute value function, and the second line plots
4970the square root and logarithm functions, both from 10 to 20 at increments of 0.1.
71+ The last line shows how to use Julia's ` do ` syntax to plot complicated anonymous functions.
5072
51- julia> using Polynomial
52- julia> x = Poly([1,0])
53- julia> Plotly.plot(3x^3 + 2x^2 - x + 1)
73+ ``` julia
74+ julia> using Polynomial
75+ julia> x = Poly ([1 ,0 ])
76+ julia> Plotly. plot (3 x^ 3 + 2 x^ 2 - x + 1 )
77+ julia> Plotly. plot ([x, 2 x, 3 x^ 2 - x])
78+ ```
5479
55- If you have the Polynomial package installed , you can plot them directly the same way as math functions.
80+ Using the Polynomial package, you can plot polynomials directly the same way as math functions.
5681
57- ## Plot TimeSeries
58- julia> using TimeSeries
59- julia> d = [date(2012,5,29):date(2013,5,29)]
60- julia> t = TimeArray(d, rand(length(d),2), ["foo","bar"])
61- julia> Plotly.plot(t)
62-
63- If you have the TimeSeries package installed, you can plot them directly by passing a TimeArray argument.
64-
65- ## Plot WAV Files
66- julia> using WAV
67- julia> Plotly.plot(wavread("filename.wav"))
68-
69- If you have the WAV package installed, you can plot WAV files by passing a call to the wavread function.
82+ ## DataFrames and TimeSeries
83+ ``` julia
84+ julia> using DataFrames
85+ julia> df = readtable (" height_vs_weight.csv" )
86+ julia> Plotly. plot (df, [" xs" => :height , " ys" => :weight ])
87+ ```
88+
89+ Using the DataFrames package, you can read CSV data and plot it directly by passing the data frame and setting the xs and/or ys options. These are symbols or arrays of symbols refering to columns names in the CSV file.
90+
91+ ``` julia
92+ julia> using TimeSeries
93+ julia> d = [date (2012 ,5 ,29 ): date (2013 ,5 ,29 )]
94+ julia> t = TimeArray (d, rand (length (d),2 ), [" foo" ," bar" ])
95+ julia> Plotly. plot (t)
96+ ```
97+
98+ Using the TimeSeries package, you can plot them directly by passing a TimeArray argument.
99+
100+ ## WAV Files
101+ ``` julia
102+ julia> using WAV
103+ julia> Plotly. plot (wavread (" filename.wav" ))
104+ ```
105+
106+ Using the WAV package, you can plot WAV files by passing a call to the ` wavread ` function.
107+
108+ # Detailed Plotting
109+ ## Arrays and Dicts
110+ ``` julia
111+ julia> trace1 = Plotly. line ([3 x for x in 1 : 1000 ])
112+ julia> trace2 = Plotly. histogram ([3 x for x in 1 : 1000 ])
113+ julia> trace3 = Plotly. scatter ([2 x => 3 x for x in 1 : 1000 ])
114+ julia> trace4 = Plotly. box ([2 x => 3 x for x in 1 : 1000 ])
115+ julia
116+ ```
117+
118+ ## Functions and Polynomials
119+ ``` julia
120+ julia> trace1 = Plotly. line (abs, [" left" => 10 , " right" => 20 , " step" => 0.1 ])
121+ julia> trace2 = Plotly. box (sin, [" left" => 10 , " right" => 20 , " step" => 0.1 ])
122+ julia> trace3 = Plotly. scatter (cos, [" left" => 10 , " right" => 20 , " step" => 0.1 ])
123+ julia> trace4 = Plotly. histogram (cos, [" left" => 10 , " right" => 20 , " step" => 0.1 ])
124+ julia> Plotly. plot ([trace1, trace2, trace3, trace4])
125+
126+ julia> using Polynomial
127+ julia> x = Poly ([1 ,0 ])
128+ julia> trace1 = Plotly. line (3 x^ 3 + 2 x^ 2 - x + 1 )
129+ julia> trace2 = Plotly. histogram (3 x^ 3 + 2 x^ 2 - x + 1 )
130+ julia> Plotly. plot ([trace1, trace2])
131+ ```
132+
133+ ## DataFrames and TimeSeries
134+ ``` julia
135+ julia> using DataFrames
136+ julia> df = readtable (" height_vs_weight.csv" )
137+ julia> trace1 = Plotly. line (df, [" xs" => :height , " ys" => :weight ])
138+ julia> trace2 = Plotly. scatter (df, [" xs" => :height , " ys" => :weight ])
139+ julia> trace3 = Plotly. histogram (df, [" xs" => :height ])
140+ julia> trace4 = Plotly. box (df, [" ys" => :weight ])
141+ julia> Plotly. plot ([trace1, trace2, trace3, trace4])
142+
143+ julia> using TimeSeries
144+ julia> d = [date (2012 ,5 ,29 ): date (2013 ,5 ,29 )]
145+ julia> t = TimeArray (d, rand (length (d),2 ), [" foo" ," bar" ])
146+ julia> trace1 = Plotly. line (t)
147+ julia> trace2 = Plotly. scatter (t)
148+ julia> trace3 = Plotly. box (t)
149+ julia> trace4 = Plotly. histogram (t)
150+ julia> Plotly. plot ([trace1, trace2, trace3, trace4])
151+ ```
152+
153+ ## WAV Files
154+ ``` julia
155+ julia> using WAV
156+ julia> trace1 = Plotly. line (wavread (" filename.wav" ))
157+ julia> trace2 = Plotly. histogram (wavread (" filename.wav" ))
158+ julia> trace3 = Plotly. box (wavread (" filename.wav" ))
159+ julia> trace4 = Plotly. scatter (wavread (" filename.wav" ))
160+ julia> Plotly. plot ([trace1, trace2, trace3, trace4])
161+ ```
0 commit comments