Skip to content

Commit 3612f28

Browse files
committed
Merge pull request #21 from plotly/jmm/new
Delegate plotting functionality to PlotlyJS
2 parents 104627e + 69a389d commit 3612f28

File tree

9 files changed

+148
-536
lines changed

9 files changed

+148
-536
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.tags*

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ os:
44
- osx
55
julia:
66
- release
7-
- nightly
87
notifications:
98
email: false

LICENSE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
The Plotly.jl package is licensed under the MIT "Expat" License:
22

3-
> Copyright (c) 2015:
3+
> Copyright (c) 2016:
44
> * Shilei Zheng
55
> * Leah Hanson
66
> * Bryan A. Knowles
77
> * chriddyp
8-
>
8+
> * Jon Malmaud
9+
910
> Permission is hereby granted, free of charge, to any person obtaining
1011
> a copy of this software and associated documentation files (the
1112
> "Software"), to deal in the Software without restriction, including

README.md

Lines changed: 28 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,75 @@
1-
# A Julia interface to the plot.ly API
1+
# A Julia interface to the plot.ly plotting library and cloud services
22

33
[![Build Status](https://travis-ci.org/plotly/Plotly.jl.svg)](https://travis-ci.org/plotly/Plotly.jl)
44

5-
README quickly to get started. Alternately, checkout out the pretty Julia docs at https://plot.ly/julia/
6-
75
## Installation
86

9-
Given that you have Julia v0.2.1,
7+
Simply run `Pkg.add("Plotly")`.
108

11-
```julia
12-
Pkg.clone("https://github.com/plotly/Plotly.jl")
13-
```
9+
## Plotting
10+
11+
Plotting functions provided by this package are identical to [PlotlyJS](https://github.com/spencerlyon2/PlotlyJS.jl). Please consult its [documentation](http://spencerlyon.com/PlotlyJS.jl/).
12+
13+
For example, this will display a basic scatter plot:
1414

15-
## Usage
16-
```julia
17-
julia> using Plotly
18-
INFO: Cloning Plotly from https://github.com/plotly/Plotly.jl
19-
INFO: Computing changes...
20-
INFO: No packages to install, update or remove.
15+
```
16+
my_plot = plot([scatter(x=[1,2], y=[3,4])], Layout(title="My plot"))
2117
```
2218

23-
You'll need to create a plot.ly account and find out your API key before you'll be able to use this package.
19+
## Using the Plotly cloud
2420

25-
## New user signup
21+
### New user signup
2622
Find your username and API key in the [Plotly settings](https://plot.ly/settings).
2723

28-
## Signin
24+
### Signin
2925
```julia
3026
julia> Plotly.signin("username","your api key")
3127
PlotlyAccount("username","your api key")
3228
```
3329

34-
Note: you may also specify your session endpoints using signin as follows:
30+
Note: you may also specify your session endpoints using signin as follows:
3531

3632
```julia
3733
julia> Plotly.signin("username","your api key",Dict("plotly_domain"=> "your_plotly_base_endpoint", "plotly_api_domain"=> "your_plotly_api_endpoint"))
3834
```
3935

40-
## Saving your credentials
36+
### Saving your credentials
4137
```julia
4238
julia> Plotly.set_credentials_file(Dict("username"=>"your_user_name","api_key"=>"your_api_key"))
4339
```
4440

4541
Note: your credentials will be saved within /YOUR_HOME_DIR/.plotly/.credentials
4642

47-
## Saving your endpoint configuration
43+
### Saving your endpoint configuration
4844
```julia
4945
julia> Plotly.set_config_file(Dict("plotly_domain"=> "your_plotly_base_endpoint", "plotly_api_domain"=> "your_plotly_api_endpoint"))
5046
```
5147

5248
Note: your configuration will be saved within /YOUR_HOME_DIR/.plotly/.config
5349

54-
## Plot && Open in browser
55-
```julia
56-
julia> Plotly.openurl(Plotly.plot(["z"=>rand(6,6)],["style"=>["type"=>"heatmap"]]))
57-
START /bin/firefox "https://plot.ly/~astrieanna/0"
58-
```
59-
60-
That last line is what the REPL prints out,
61-
as a Firefox tab opens with the plot.
62-
You can also just call `plot` by itself, and you'll get a String that's the url of your chart.
63-
64-
## Style and Layout
65-
```julia
66-
julia> Plotly.style(["line"=>["color"=>"rgb(255,0,0)","width"=>10]])
67-
julia> Plotly.layout(["layout"=>["title"=>"Time Wasted"]])
68-
```
69-
70-
# Quick Plotting
71-
## Functions and Polynomials
72-
```julia
73-
julia> Plotly.plot(abs)
74-
julia> Plotly.plot([sqrt, log], ["left"=>10, "right"=>20, "step"=>0.1])
75-
julia> Plotly.plot() do x
76-
savings = 3000
77-
income = x*1000
78-
expenses = x*800
79-
return savings+income-expenses
80-
end
81-
```
50+
### Saving a plot to the cloud
8251

83-
You can now plot functions directly.
84-
The first line shows how to plot the absolute value function, and the second line plots
85-
the square root and logarithm functions, both from 10 to 20 at increments of 0.1.
86-
The last line shows how to use Julia's `do` syntax to plot complicated anonymous functions.
52+
Use the `post` function to upload a local plot to the Plotly cloud:
8753

88-
```julia
89-
julia> using Polynomial
90-
julia> x = Poly([1,0])
91-
julia> Plotly.plot(3x^3 + 2x^2 - x + 1)
92-
julia> Plotly.plot([x, 2x, 3x^2-x])
9354
```
94-
95-
Using the Polynomial package, you can plot polynomials directly the same way as math functions.
96-
97-
## DataFrames and TimeSeries
98-
```julia
99-
julia> using DataFrames
100-
julia> df = readtable("height_vs_weight.csv")
101-
julia> Plotly.plot(df, ["xs"=>:height, "ys"=>:weight])
55+
> my_plot = plot([scatter(y=[1,2])])
56+
> remote_plot = post(my_plot)
57+
Plotly.RemotePlot(URI(https://plot.ly/~malmaud/73))
10258
```
10359

104-
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.
60+
Visiting <https://plot.ly/~malmaud/73> in a browser will show the plot.
10561

106-
```julia
107-
julia> using TimeSeries
108-
julia> d = [date(2012,5,29):date(2013,5,29)]
109-
julia> t = TimeArray(d, rand(length(d),2), ["foo","bar"])
110-
julia> Plotly.plot(t)
111-
```
62+
### Download a plot from the cloud
11263

113-
Using the TimeSeries package, you can plot them directly by passing a TimeArray argument.
64+
Use the `download` function with a remote plot object to download a plot stored on the Plotly cloud to a local `Plot` object:
11465

115-
## WAV Files
116-
```julia
117-
julia> using WAV
118-
julia> Plotly.plot(wavread("filename.wav"))
11966
```
120-
121-
Using the WAV package, you can plot WAV files by passing a call to the `wavread` function.
122-
123-
# Detailed Plotting
124-
## Arrays and Dicts
125-
```julia
126-
julia> trace1 = Plotly.line([3x for x in 1:1000])
127-
julia> trace2 = Plotly.histogram([3x for x in 1:1000])
128-
julia> trace3 = Plotly.scatter([2x => 3x for x in 1:1000])
129-
julia> trace4 = Plotly.box([2x => 3x for x in 1:1000])
130-
julia
67+
local_plot = download(RemotePlot("https://plot.ly/~malmaud/73"))
68+
# or equivalently, local_plot = download_plot("https://plot.ly/~malmaud/73")
13169
```
13270

133-
## Functions and Polynomials
134-
```julia
135-
julia> trace1 = Plotly.line(abs, ["left"=>10, "right"=>20, "step"=>0.1])
136-
julia> trace2 = Plotly.box(sin, ["left"=>10, "right"=>20, "step"=>0.1])
137-
julia> trace3 = Plotly.scatter(cos, ["left"=>10, "right"=>20, "step"=>0.1])
138-
julia> trace4 = Plotly.histogram(cos, ["left"=>10, "right"=>20, "step"=>0.1])
139-
julia> Plotly.plot([trace1, trace2, trace3, trace4])
140-
141-
julia> using Polynomial
142-
julia> x = Poly([1,0])
143-
julia> trace1 = Plotly.line(3x^3 + 2x^2 - x + 1)
144-
julia> trace2 = Plotly.histogram(3x^3 + 2x^2 - x + 1)
145-
julia> Plotly.plot([trace1, trace2])
146-
```
14771

148-
## DataFrames and TimeSeries
149-
```julia
150-
julia> using DataFrames
151-
julia> df = readtable("height_vs_weight.csv")
152-
julia> trace1 = Plotly.line(df, ["xs"=>:height, "ys"=>:weight])
153-
julia> trace2 = Plotly.scatter(df, ["xs"=>:height, "ys"=>:weight])
154-
julia> trace3 = Plotly.histogram(df, ["xs"=>:height])
155-
julia> trace4 = Plotly.box(df, ["ys"=>:weight])
156-
julia> Plotly.plot([trace1, trace2, trace3, trace4])
157-
158-
julia> using TimeSeries
159-
julia> d = [date(2012,5,29):date(2013,5,29)]
160-
julia> t = TimeArray(d, rand(length(d),2), ["foo","bar"])
161-
julia> trace1 = Plotly.line(t)
162-
julia> trace2 = Plotly.scatter(t)
163-
julia> trace3 = Plotly.box(t)
164-
julia> trace4 = Plotly.histogram(t)
165-
julia> Plotly.plot([trace1, trace2, trace3, trace4])
166-
```
72+
### Acknowledgements
73+
[PlotlyJS.jl ](https://github.com/spencerlyon2/PlotlyJS.jl), which provides the large majority of the functionality of this package, is developed primarily by Spencer Lyon.
16774

168-
## WAV Files
169-
```julia
170-
julia> using WAV
171-
julia> trace1 = Plotly.line(wavread("filename.wav"))
172-
julia> trace2 = Plotly.histogram(wavread("filename.wav"))
173-
julia> trace3 = Plotly.box(wavread("filename.wav"))
174-
julia> trace4 = Plotly.scatter(wavread("filename.wav"))
175-
julia> Plotly.plot([trace1, trace2, trace3, trace4])
176-
```
75+
This package, which adds to PlotlyJS.jl the functionality for interacting with the Plotly cloud, is developed by Jon Malmaud and others.

REQUIRE

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
Requests
1+
julia 0.4
2+
Requests 0.3.5
23
JSON
4+
PlotlyJS 0.2.0
5+
Compat 0.7.20
6+
Reexport

0 commit comments

Comments
 (0)