display_methods
index
/home/gcallah/TandonDevOps/IndraABM/lib/display_methods.py

Filename: display_methods.py
Author: Gene Callahan
A collection of convenience functions
for using matplotlib.

 
Modules
       
io
logging
matplotlib
numpy
pandas
matplotlib.pyplot
seaborn
sys

 
Classes
       
builtins.object
BarGraph
LineGraph
ScatterPlot

 
class BarGraph(builtins.object)
    BarGraph(title, varieties, data_points, anim=False, data_func=None, is_headless=False, legend_pos=4)
 

 
  Methods defined here:
__init__(self, title, varieties, data_points, anim=False, data_func=None, is_headless=False, legend_pos=4)
Initialize self.  See help(type(self)) for accurate signature.
create_bars(self, x, ax, varieties)
draw_graph(self, data_points, varieties)
Draw all elements of the graph.
show(self)
Display the barGraph.
update_plot(self, i)
This is our animation function.
For line graphs, redraw the whole thing.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LineGraph(builtins.object)
    LineGraph(title, varieties, data_points, attrs, anim=False, data_func=None, is_headless=False)
 
We create a class here to save state for animation.
Display a simple matplotlib line graph.
The data is a dictionary with the label
as the key and a list of numbers as the
thing to graph.
data_points is the length of the x-axis.
 
  Methods defined here:
__init__(self, title, varieties, data_points, attrs, anim=False, data_func=None, is_headless=False)
Initialize self.  See help(type(self)) for accurate signature.
create_lines(self, x, varieties)
Draw just the data portion.
draw_graph(self, data_points, varieties, attrs)
Draw all elements of the graph.
show(self)
Display the plot.
update_plot(self, i)
This is our animation function.
For line graphs, redraw the whole thing.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ScatterPlot(builtins.object)
    ScatterPlot(title, varieties, width, height, attrs, anim=True, data_func=None, is_headless=False)
 
We are going to use a class here to save state for our animation
 
  Methods defined here:
__init__(self, title, varieties, width, height, attrs, anim=True, data_func=None, is_headless=False)
Setup a scatter plot.
`varieties` contains the different types of entities to show in the
plot, which will get assigned different colors and perhaps markers.
create_scats(self, varieties)
draw_graph(self, title, width, height, varieties, attrs)
get_arrays(self, varieties, var)
show(self)
Display the plot.
update_plot(self, i)
This is our animation function.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
are_graphics_present()
draw_graph(graph, title, hierarchy=False, root=None)
Drawing networkx graphs.
graph is the graph to draw.
hierarchy is whether we should draw it as a tree.
Network drawings not yet implemented in V3.
expects_plt(fn)
Should be used to decorate any function that uses matplotlib's pyplot.
get_color(var, i)
get_marker(var, i)
hierarchy_pos(graph, root, width=1.0, vert_gap=0.2, vert_loc=0.0, xcenter=0.5, pos=None, parent=None)
This is an attempt to get a tree graph from networkx.
If there is a cycle that is reachable from root, then this will
infinitely recurse.
graph: the graph
root: the root node of current branch
width: horizontal space allocated for this branch
        - avoids overlap with other branches
vert_gap: gap between levels of hierarchy
vert_loc: vertical location of root
xcenter: horizontal location of root
pos: a dict saying where all nodes go if they have been assigned
parent: parent of this branch.

 
Data
        API = 'api'
BLACK = 'black'
BLUE = 'blue'
CIRCLE = 'circle'
CYAN = 'cyan'
DARKRED = 'darkred'
DEBUG = <lib.utils.Debug object>
DECEASED = 'deceased'
DEFAULT_MARKER = 'default'
DEF_SIZE = 40
GRAY = 'gray'
GREEN = 'green'
LIMEGREEN = 'limegreen'
MAGENTA = 'magenta'
NAVY = 'navy'
NUM_COLORS = 18
ORANGE = 'orange'
ORANGERED = 'orangered'
PERSON = 'person'
PURPLE = 'purple'
RED = 'red'
SPRINGGREEN = 'springgreen'
SQUARE = 'square'
TAN = 'tan'
TERMINAL = 'terminal'
TOMATO = 'tomato'
TREE = 'tree'
WHITE = 'white'
X = 0
Y = 1
YELLOW = 'yellow'
anim_func = None
colors = ['red', 'blue', 'green', 'navy', 'springgreen', 'orange', 'limegreen', 'yellow', 'cyan', 'tan', 'orangered', 'tomato', 'darkred', 'magenta', 'black', 'gray', 'purple', 'white']
colors_dict = {'black': 'black', 'blue': 'blue', 'cyan': 'cyan', 'darkred': 'darkred', 'gray': 'gray', 'green': 'green', 'limegreen': 'limegreen', 'magenta': 'magenta', 'navy': 'navy', 'orange': 'orange', ...}
graphics_present = False
markers = {'circle': 'o', 'deceased': 'x', 'default': '8', 'person': 'o', 'square': 's', 'tree': '^'}
no_graphics_msg = "Cannot load backend 'TkAgg' which requires the '...ive framework, as 'headless' is currently running"
seaborn_markers = ['8', 's', '^', 'o', 'x']
user_type = 'test'