Plots.jl/examples/spy.ipynb
2015-10-04 21:39:32 -05:00

108 lines
1.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Plots.jl] Default backend: immerse"
]
}
],
"source": [
"using Plots\n",
"n = 1000\n",
"a = rand(n)\n",
"y = Float64[i*a[i]+j*a[j] for i in 1:n, j in 1:n]\n",
"y = float(y .> mean(y));"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"[Plots.jl] Initializing backend: immerse"
]
}
],
"source": [
"spy(y, nbins=(20,100))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# get the indices (I,J) and the values (V) of non-zero values in y\n",
"I,J,V = findnz(y);\n",
"# plot the J's vs the I's in a heatmap to recreate the spy call\n",
"heatmap(J,I)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pyplot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"histogram(randn(1000), "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.4.0-rc2",
"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
}