working on unicodeplots savepng and examples
@ -48,7 +48,7 @@ const examples = PlotExample[
|
||||
[:(heatmap(randn(10000),randn(10000); nbins=200))]),
|
||||
PlotExample("Lots of line types",
|
||||
"Options: (:line, :step, :stepinverted, :sticks, :dots, :none, :heatmap, :hexbin, :hist, :bar) \nNote: some may not work with all backends",
|
||||
[:(plot(rand(20,4); linetypes=[:line, :step, :sticks, :dots]))]),
|
||||
[:(plot(rand(20,4); linetypes=[:line, :step, :sticks, :dots], labels=["line","step","sticks","dots"]))]),
|
||||
PlotExample("Bar",
|
||||
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
|
||||
[:(bar(randn(1000)))]),
|
||||
@ -114,7 +114,8 @@ function generate_markdown(pkgname::Symbol)
|
||||
end
|
||||
|
||||
# run it!
|
||||
map(generate_markdown, (:qwt, :gadfly, :unicodeplots))
|
||||
# map(generate_markdown, (:qwt, :gadfly))
|
||||
generate_markdown(:unicodeplots) # generate separately so it's easy to comment out
|
||||
|
||||
|
||||
end # module
|
||||
|
||||
@ -86,7 +86,7 @@ Options: (:line, :step, :stepinverted, :sticks, :dots, :none, :heatmap, :hexbin,
|
||||
Note: some may not work with all backends
|
||||
|
||||
```julia
|
||||
plot(rand(20,4); linetypes=[:line,:step,:sticks,:dots])
|
||||
plot(rand(20,4); linetypes=[:line,:step,:sticks,:dots],labels=["line","step","sticks","dots"])
|
||||
```
|
||||
|
||||

|
||||
@ -111,3 +111,38 @@ histogram(randn(1000); nbins=50,fillto=20)
|
||||
|
||||

|
||||
|
||||
### Subplots
|
||||
|
||||
subplot and subplot! are distinct commands which create many plots and add series to them in a circular fashion.
|
||||
You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or
|
||||
number of columns `nc`), or you can set the layout directly with `layout`.
|
||||
|
||||
Note: Gadfly is not very friendly here, and although you can create a plot and save a PNG, I haven't been able to actually display it.
|
||||
|
||||
|
||||
```julia
|
||||
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:dots,:step,:bar],nbins=10,legend=false)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Adding to subplots
|
||||
|
||||
Note here the automatic grid layout, as well as the order in which new series are added to the plots.
|
||||
|
||||
```julia
|
||||
subplot(randn(100,5); n=4)
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
|
||||
|
||||
|
||||
```julia
|
||||
subplot!(randn(100,3))
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 468 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 271 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 55 KiB |
BIN
img/unicodeplots_example_13.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
img/unicodeplots_example_14.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
img/unicodeplots_example_15.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 215 KiB After Width: | Height: | Size: 55 KiB |
@ -114,27 +114,46 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
function savepng(::UnicodePlotsPackage, plt::PlottingObject, fn::String, args...) # = error("currently unsupported")
|
||||
function savepng(::UnicodePlotsPackage, plt::PlottingObject, fn::String, args...)
|
||||
|
||||
# make some whitespace and show the plot
|
||||
println("\n\n\n\n\n\n")
|
||||
display(plt)
|
||||
try
|
||||
|
||||
@osx_only begin
|
||||
# BEGIN HACK
|
||||
|
||||
# wait while the plot gets drawn
|
||||
sleep(0.5)
|
||||
|
||||
# use osx screen capture when my terminal is maximized and cursor starts at the bottom (I know, right?)
|
||||
# TODO: compute size of plot to adjust these numbers (or maybe implement something good??)
|
||||
run(`screencapture -R50,600,700,420 $fn`)
|
||||
|
||||
# # some other attempts:
|
||||
# run(`screencapture -w $fn`)
|
||||
using PyCall
|
||||
@pyimport pyscreenshot as pss
|
||||
# todo: grab screen to $fn
|
||||
# using PyCall
|
||||
# @pyimport pyscreenshot as pss
|
||||
|
||||
# END HACK (phew)
|
||||
return
|
||||
end
|
||||
error("Can only savepng on osx with UnicodePlots.")
|
||||
|
||||
error("Can only savepng on osx with UnicodePlots (though even then I wouldn't do it)")
|
||||
end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
# create the underlying object (each backend will do this differently)
|
||||
# we don't do very much for subplots... just stack them vertically
|
||||
|
||||
function buildSubplotObject!(::UnicodePlotsPackage, subplt::Subplot)
|
||||
error("UnicodePlots doesn't support subplots")
|
||||
nothing
|
||||
end
|
||||
|
||||
|
||||
function Base.display(::UnicodePlotsPackage, subplt::Subplot)
|
||||
error("UnicodePlots doesn't support subplots")
|
||||
for plt in subplt.plts
|
||||
display(UnicodePlotsPackage(), plt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||