cppyabm  1.0.17
An agent-based library to integrate C++ and Python
plot_cellcount.py
Go to the documentation of this file.
1 import plotly.graph_objs as go
2 import plotly.express as px
3 import numpy as np
4 import pandas as pd
5 line_types = ['solid', 'dot', 'dash', 'dashdot', 'dashdot', 'longdashdot']
6 colors = ['DarkSlateGrey','DarkSeaGreen','DarkViolet','red']
7 def lines(data,name,x_lims,y_lims):
8  fig = go.Figure()
9  i =0
10  for key,value in data.items():
11  fig.add_trace(go.Scatter(
12  y=value,
13  name=key,
14  line = dict(width=3, dash=line_types[i],color =colors[i] )
15  ))
16  i+=1
17 
18  fig.update_layout(
19  width=550, #TODO: to go
20  height=500,#TODO: to go
21  title=dict(
22  y= 0.9,
23  x= 0.5,
24  xanchor= 'center',
25  yanchor= 'top',
26  font=dict(
27  family='sans-serif',
28  size=20,
29  color='DarkSlateGrey'
30  )),
31 
32  xaxis = dict(
33  showgrid=True,
34  mirror=True,
35  showline=True,
36  # zeroline = False,
37  linecolor = 'black',
38  gridwidth = 20,
39  tickfont = dict(
40  family = 'Times New Roman',
41  size = 30,
42  color = 'black'
43  ),
44  range= x_lims
45  ),
46 
47  yaxis = dict(
48  showgrid=True,
49  mirror=True,
50  showline=True,
51  linecolor = 'black',
52  gridwidth = 20,
53  dtick=1000,#TODO: to go
54  tickfont = dict(
55  family = 'Times New Roman',
56  size = 30,
57  color = 'black'
58  ),
59  zeroline = False,
60  # range =
61  # [min([min(data[key]) for key in data.keys()]) - 0.5,
62  # max([max(data[key]) for key in data.keys()]) + 0.5]),
63  range = y_lims),#TODO: to go
64 
65  paper_bgcolor='rgba(0,0,0,0)',
66  plot_bgcolor='rgba(0,0,0,0)',
67  legend=dict(
68  orientation="h",
69  x=.03,
70  y=1.2,
71  font=dict(
72  family='Times New Roman',
73  size=30,
74  color='#000'
75  ),
76  bordercolor='DarkSeaGreen'
77  # borderwidth=1
78  ),
79  margin=dict(
80  l=50,
81  r=50,
82  b=100,
83  t=100,
84  pad=4
85  )
86  )
87 
88  fig.update_yaxes(automargin=True,showgrid=False,zeroline=False)
89  fig.update_xaxes(automargin=True,showgrid=False,zeroline=False)
90  fig.write_image(name+'.svg')
91 
92 def process(postfixes,plot_name):
93  def extract_data(postfix):
94  data = pd.read_csv('cell_count_{}.csv'.format(postfix))
95  # process to remove unwanted coloumn
96  if "Unnamed: 0" in data.keys():
97  data = data.drop("Unnamed: 0", axis=1)
98  return data
99  data = map(lambda postfix: extract_data(postfix),postfixes)
100  # concatenate data sets
101  data = pd.concat(data, axis=1)
102  x_lims = [-.5,338]
103  y_lims = [1000,5050]
104  # change the column names
105  data.columns = postfixes
106  lines(data,plot_name,x_lims= x_lims,y_lims=y_lims)
107 
108 
109 if __name__ == '__main__':
110  postfixes = ['Cpp','Py','Cppy','Pyy']
111  process(postfixes,'all')
112  postfixes = ['Cpp','Py']
113  process(postfixes,'Cpp_Py')
114 
115 
dict
Definition: pytypes.h:1299
plot_cellcount.lines
def lines(data, name, x_lims, y_lims)
Definition: plot_cellcount.py:7
plot_cellcount.process
def process(postfixes, plot_name)
Definition: plot_cellcount.py:92