pyplot fixes and examples
@ -1,8 +1,8 @@
|
|||||||
# Examples for backend: pyplot
|
# Examples for backend: pyplot
|
||||||
|
|
||||||
- Supported arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
|
- Supported arguments: `args`, `axis`, `background_color`, `color`, `foreground_color`, `group`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `ribbon`, `show`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `xticks`, `ylabel`, `yrightlabel`, `yticks`
|
||||||
- Supported values for axis: `:auto`, `:left`, `:right`
|
- Supported values for axis: `:auto`, `:left`, `:right`
|
||||||
- Supported values for linetype: `:none`, `:line`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
|
- Supported values for linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
|
||||||
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
|
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
|
||||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon`
|
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon`
|
||||||
- Is `subplot`/`subplot!` supported? No
|
- Is `subplot`/`subplot!` supported? No
|
||||||
@ -19,7 +19,7 @@ pyplot!()
|
|||||||
A simple line plot of the 3 columns.
|
A simple line plot of the 3 columns.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(rand(100,3))
|
plot(rand(50,5),w=3)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
|||||||
```julia
|
```julia
|
||||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||||
sin(2x)
|
sin(2x)
|
||||||
end),0,2π,legend=false)
|
end),0,2π,legend=false,fillto=0)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -61,7 +61,7 @@ plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, li
|
|||||||
Change the guides/background without a separate call.
|
Change the guides/background without a separate call.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.5,0.5,0.5))
|
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -73,7 +73,7 @@ Use the `axis` or `axiss` arguments.
|
|||||||
Note: Currently only supported with Qwt and PyPlot
|
Note: Currently only supported with Qwt and PyPlot
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right],ylabel="LEFT",yrightlabel="RIGHT")
|
plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel="RIGHT")
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -103,7 +103,7 @@ plot(rand(100) / 3; reg=true,fillto=0)
|
|||||||
and add to it later.
|
and add to it later.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
scatter!(rand(100); markersize=6,color=:blue)
|
scatter!(rand(100); markersize=6,c=:blue)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -123,11 +123,11 @@ heatmap(randn(10000),randn(10000); nbins=100)
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||||
n = length(types)
|
n = length(types)
|
||||||
x = Vector[sort(rand(20)) for i = 1:n]
|
x = Vector[sort(rand(20)) for i = 1:n]
|
||||||
y = rand(20,n)
|
y = rand(20,n)
|
||||||
plot(x,y; linetypes=types,labels=map(string,types))
|
plot(x,y; t=types,lab=map(string,types))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -138,7 +138,7 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
|||||||
|
|
||||||
```julia
|
```julia
|
||||||
styles = setdiff(supportedStyles(),[:auto])
|
styles = setdiff(supportedStyles(),[:auto])
|
||||||
plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -149,7 +149,7 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
|||||||
|
|
||||||
```julia
|
```julia
|
||||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),markersize=10)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -166,10 +166,10 @@ bar(randn(1000))
|
|||||||
|
|
||||||
### Histogram
|
### Histogram
|
||||||
|
|
||||||
note: fillto isn't supported on all backends
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
histogram(randn(1000); nbins=50,fillto=20)
|
histogram(randn(1000); nbins=50)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 363 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 48 KiB |
@ -67,7 +67,7 @@ function getPyPlotFunction(plt::Plot, axis::Symbol, linetype::Symbol)
|
|||||||
|
|
||||||
# in the 2-axis case we need to get: <rightaxis>[:<func>]
|
# in the 2-axis case we need to get: <rightaxis>[:<func>]
|
||||||
if axis == :right
|
if axis == :right
|
||||||
ax = getRightAxis(plt.o)
|
ax = getRightAxis(plt.o[1])
|
||||||
ax[:set_ylabel](plt.initargs[:yrightlabel])
|
ax[:set_ylabel](plt.initargs[:yrightlabel])
|
||||||
fmap = Dict(
|
fmap = Dict(
|
||||||
:hist => :hist,
|
:hist => :hist,
|
||||||
@ -221,7 +221,14 @@ function updatePlotItems(plt::Plot{PyPlotPackage}, d::Dict)
|
|||||||
makePyPlotCurrent(plt)
|
makePyPlotCurrent(plt)
|
||||||
haskey(d, :title) && PyPlot.title(d[:title])
|
haskey(d, :title) && PyPlot.title(d[:title])
|
||||||
haskey(d, :xlabel) && PyPlot.xlabel(d[:xlabel])
|
haskey(d, :xlabel) && PyPlot.xlabel(d[:xlabel])
|
||||||
haskey(d, :ylabel) && PyPlot.ylabel(d[:ylabel])
|
if haskey(d, :ylabel)
|
||||||
|
ax = getLeftAxis(plt.o[1])
|
||||||
|
ax[:set_ylabel](d[:ylabel])
|
||||||
|
end
|
||||||
|
if haskey(d, :yrightlabel)
|
||||||
|
ax = getRightAxis(plt.o[1])
|
||||||
|
ax[:set_ylabel](d[:yrightlabel])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||