Plots.jl/examples/facets.ipynb
2015-10-09 14:35:00 -04:00

158 lines
3.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Plots.jl] Switched to backend: gadfly\n"
]
}
],
"source": [
"using Plots\n",
"gadfly()\n",
"default(leg=false,size=(400,400));\n",
"#debugplots();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"y = linspace(0,1,100)\n",
"p = subplot(repmat(y,1,4),n=4)\n",
"subplot!(ylabel=[\"y1\",\"y1\",\"y2\",\"y2\"], xlabel=[\"x1\",\"x2\",\"x1\",\"x2\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"function addOrReplace(v::AbstractVector, t::DataType, args...; kw...)\n",
" for (i,vi) in enumerate(v)\n",
" if isa(guide, t)\n",
" gplt.guides[i] = t(args...; kw...)\n",
" end\n",
" end\n",
"end\n",
"\n",
"\n",
"# findGuideAndSet(gplt, t::DataType, s::@compat(AbstractString))\n",
"for (i,(r,c)) in enumerate(p.layout)\n",
" gplt = p.plts[i].o\n",
" if r < Plots.nrows(p.layout)\n",
" push!(gplt.guides, Gadfly.Guide.xticks(label=false))\n",
" Plots.findGuideAndSet(gplt, Gadfly.Guide.xlabel, \"\")\n",
" end\n",
" if c > 1\n",
" #push!(gplt.guides, Gadfly.Guide.yticks(label=false))\n",
" Plots.findGuideAndSet(gplt, Gadfly.Guide.yticks, label=false)\n",
" Plots.findGuideAndSet(gplt, Gadfly.Guide.ylabel, \"\")\n",
" end\n",
"end\n",
"#p1 = p.plts[1].o\n",
"#push!(p1.guides, Gadfly.Guide.xticks(label=false,ticks=nothing))\n",
"p"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# link the subplots together to share axes... useful for facet plots, cross-scatters, etc\n",
"function linkXAxis(subplt::Plots.Subplot{Plots.GadflyPackage, Plots.GridLayout})\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"p = subplot(repmat(y,1,4),layout=[1,1,2])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"fl = FlexLayout(5, [2,1,2])\n",
"gl = GridLayout(3,2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"for (r,c) in gl\n",
" @show r,c\n",
"end\n",
"length(gl)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.4.0-rc4",
"language": "julia",
"name": "julia-0.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.4.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}