Skip to content

Commit

Permalink
Improvements to labelling of plots etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Deschamps committed Apr 11, 2017
1 parent eea71bb commit 228b74c
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 72 deletions.
139 changes: 101 additions & 38 deletions descriptor/.ipynb_checkpoints/create_graphs_in_R-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,82 @@
"cells": [
{
"cell_type": "code",
"execution_count": 55,
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"Attaching package: ‘igraph’\n",
"\n",
"The following objects are masked from ‘package:stats’:\n",
"\n",
" decompose, spectrum\n",
"\n",
"The following object is masked from ‘package:base’:\n",
"\n",
" union\n",
"\n",
"network: Classes for Relational Data\n",
"Version 1.13.0 created on 2015-08-31.\n",
"copyright (c) 2005, Carter T. Butts, University of California-Irvine\n",
" Mark S. Handcock, University of California -- Los Angeles\n",
" David R. Hunter, Penn State University\n",
" Martina Morris, University of Washington\n",
" Skye Bender-deMoll, University of Washington\n",
" For citation information, type citation(\"network\").\n",
" Type help(\"network-package\") to get started.\n",
"\n",
"\n",
"Attaching package: ‘network’\n",
"\n",
"The following objects are masked from ‘package:igraph’:\n",
"\n",
" %c%, %s%, add.edges, add.vertices, delete.edges, delete.vertices,\n",
" get.edge.attribute, get.edges, get.vertex.attribute, is.bipartite,\n",
" is.directed, list.edge.attributes, list.vertex.attributes,\n",
" set.edge.attribute, set.vertex.attribute\n",
"\n",
"Loading required package: statnet.common\n",
"\n",
"ergm: version 3.7.1, created on 2017-03-20\n",
"Copyright (c) 2017, Mark S. Handcock, University of California -- Los Angeles\n",
" David R. Hunter, Penn State University\n",
" Carter T. Butts, University of California -- Irvine\n",
" Steven M. Goodreau, University of Washington\n",
" Pavel N. Krivitsky, University of Wollongong\n",
" Martina Morris, University of Washington\n",
" with contributions from\n",
" Li Wang\n",
" Kirk Li, University of Washington\n",
" Skye Bender-deMoll, University of Washington\n",
"Based on \"statnet\" project software (statnet.org).\n",
"For license and citation information see statnet.org/attribution\n",
"or type citation(\"ergm\").\n",
"\n",
"NOTE: Versions before 3.6.1 had a bug in the implementation of the bd()\n",
"constriant which distorted the sampled distribution somewhat. In\n",
"addition, Sampson's Monks datasets had mislabeled verteces. See the\n",
"NEWS and the documentation for more details.\n",
"\n"
]
}
],
"source": [
"# Install the igraph library\n",
"library(igraph)"
"library(igraph)\n",
"library(intergraph)\n",
"library(network)\n",
"library(ergm)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -34,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 3,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -494,7 +557,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 4,
"metadata": {
"collapsed": false
},
Expand All @@ -506,26 +569,18 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1] \"Average In-degree: 0.992753623188406\"\n",
"[1] \"Average Out-degree: 0.992753623188406\"\n",
"[1] \"Average Degree: 1.98550724637681\"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning message in vattrs[[name]][index] <- value:\n",
"“number of items to replace is not a multiple of replacement length”"
"ename": "ERROR",
"evalue": "Error in print(full.vc()): could not find function \"full.vc\"\n",
"output_type": "error",
"traceback": [
"Error in print(full.vc()): could not find function \"full.vc\"\nTraceback:\n",
"1. print(full.vc())"
]
}
],
Expand Down Expand Up @@ -554,6 +609,7 @@
"weak <- weakly_connected_graph\n",
"strong <- strongly_connected_graph\n",
"\n",
"\n",
"# Change graph_plot_name to whichever of the above you'd like to plot.\n",
"\n",
"graph_plot_name <- full\n",
Expand All @@ -575,21 +631,34 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Running this code will give you the details for plotting\n",
"# in Igraph\n",
"?igraph.plotting"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ERROR",
"evalue": "Error in i.parse.plot.params(graph, list(...)): Unknown plot parameters: label.degree\n",
"evalue": "Error in paste(\"Total nodes:\", graph_plot_name.vcount(), \"\\nTotal edges:\", : could not find function \"graph_plot_name.vcount\"\n",
"output_type": "error",
"traceback": [
"Error in i.parse.plot.params(graph, list(...)): Unknown plot parameters: label.degree\nTraceback:\n",
"1. plot(graph_plot_name, layout = layout, vertex.size = log(V(graph_plot_name)$degree) * \n . 5, vertex.label = V(graph_plot_name)$rlabel, vertex.color = colors[mems], \n . vertex.frame.color = \"black\", vertex.label.color = \"black\", \n . vertex.label.font = \"\", vertex.label.cex = 1, vertex.label.dist = 0, \n . label.degree = -pi/4, vertex.shape = \"circle\", edge.width = 0.1, \n . edge.arrow.size = 0.2, edge.arrow.width = 1, edge.lty = 1, \n . )",
"2. plot.igraph(graph_plot_name, layout = layout, vertex.size = log(V(graph_plot_name)$degree) * \n . 5, vertex.label = V(graph_plot_name)$rlabel, vertex.color = colors[mems], \n . vertex.frame.color = \"black\", vertex.label.color = \"black\", \n . vertex.label.font = \"\", vertex.label.cex = 1, vertex.label.dist = 0, \n . label.degree = -pi/4, vertex.shape = \"circle\", edge.width = 0.1, \n . edge.arrow.size = 0.2, edge.arrow.width = 1, edge.lty = 1, \n . )",
"Error in paste(\"Total nodes:\", graph_plot_name.vcount(), \"\\nTotal edges:\", : could not find function \"graph_plot_name.vcount\"\nTraceback:\n",
"1. plot(graph_plot_name, main = paste(\"Network plot for ...\", file), \n . sub = paste(\"Total nodes:\", graph_plot_name.vcount(), \"\\nTotal edges:\", \n . graph_plot_name.ecount()), layout = layout, vertex.size = log(V(graph_plot_name)$degree) * \n . 5, vertex.label = V(graph_plot_name)$rlabel, vertex.color = colors[mems], \n . vertex.frame.color = \"black\", vertex.label.color = \"black\", \n . vertex.label.font = 3, vertex.label.cex = 1, vertex.label.dist = 0, \n . vertex.shape = \"circle\", edge.width = 0.1, edge.arrow.size = 0.2, \n . edge.arrow.width = 1, edge.lty = 1, )",
"2. plot.igraph(graph_plot_name, main = paste(\"Network plot for ...\", \n . file), sub = paste(\"Total nodes:\", graph_plot_name.vcount(), \n . \"\\nTotal edges:\", graph_plot_name.ecount()), layout = layout, \n . vertex.size = log(V(graph_plot_name)$degree) * 5, vertex.label = V(graph_plot_name)$rlabel, \n . vertex.color = colors[mems], vertex.frame.color = \"black\", \n . vertex.label.color = \"black\", vertex.label.font = 3, vertex.label.cex = 1, \n . vertex.label.dist = 0, vertex.shape = \"circle\", edge.width = 0.1, \n . edge.arrow.size = 0.2, edge.arrow.width = 1, edge.lty = 1, \n . )",
"3. i.parse.plot.params(graph, list(...))",
"4. stop(\"Unknown plot parameters: \", paste(sep = \", \", collapse = \", \", \n . names(p[[\"plot\"]])[mis]))"
"4. paste(\"Total nodes:\", graph_plot_name.vcount(), \"\\nTotal edges:\", \n . graph_plot_name.ecount())"
]
}
],
Expand All @@ -609,18 +678,21 @@
"# layout_on_sphere(graph_plot_name)\n",
"# layout_with_lgl(graph_plot_name)\n",
"# layout_with_fr(graph_plot_name)\n",
"# layout_with_kk(graph_plot_name)\n",
"\n",
"layout = layout_with_fr(graph_plot_name)\n",
"layout = layout_with_kk(graph_plot_name)\n",
"\n",
"\n",
"plot(graph_plot_name, \n",
" main=paste(\"Network plot for ...\", file),\n",
" sub=paste(\"Total nodes:\", graph_plot_name.vcount(), \"\\nTotal edges:\", graph_plot_name.ecount()),\n",
" layout=layout, \n",
" vertex.size=log(V(graph_plot_name)$degree)*5, \n",
" vertex.label=V(graph_plot_name)$rlabel, \n",
" vertex.color=colors[mems],\n",
" vertex.frame.color = \"black\",\n",
" vertex.label.color=\"black\", \n",
" vertex.label.font=\"\",\n",
" vertex.label.font=3,\n",
" vertex.label.cex=1,\n",
" vertex.label.dist=0,\n",
" vertex.shape = \"circle\", # can be “circle”, “square”, “csquare”, \n",
Expand All @@ -634,15 +706,6 @@
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading

0 comments on commit 228b74c

Please sign in to comment.