-
Notifications
You must be signed in to change notification settings - Fork 0
/
charts.py
59 lines (53 loc) · 2.9 KB
/
charts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
MARKER = {'type': 'circle', 'size': 4, 'border': {'color': 'blue'}, 'fill': {'color': 'white'}}
def chart_time_series(writer, workbook, values_num):
worksheet = writer.sheets['TimeSeries']
time_series_chart = workbook.add_chart({'type': 'scatter'})
time_series_chart.add_series({
'categories': ['TimeSeries', 1, 0, values_num, 0],
'values': ['TimeSeries', 1, 1, values_num, 1],
'marker': MARKER,
})
time_series_chart.set_x_axis({'name': 'x', 'position_axis': 'on_tick'})
time_series_chart.set_y_axis({'name': 'y', 'num_format': '0.00E+00', 'major_gridlines': {'visible': False}})
time_series_chart.set_legend({'position': 'none'})
time_series_chart.set_size({'width': 640, 'height': 480})
return worksheet.insert_chart('D2', time_series_chart)
def chart_spectral_density(writer, workbook, values_num):
worksheet = writer.sheets['SpectralDensity']
spectral_density_chart = workbook.add_chart({'type': 'scatter'})
spectral_density_chart.add_series({
'categories': ['SpectralDensity', 1, 0, values_num, 0],
'values': ['SpectralDensity', 1, 1, values_num, 1],
'marker': MARKER
})
spectral_density_chart.set_x_axis({'name': 'Frequency', 'major_unit': 0.1, 'minor_unit': 0.01, 'max': 0.5,
'position_axis': 'on_tick'})
spectral_density_chart.set_y_axis(
{'name': 'Spectral Density', 'num_format': '0.00E+00', 'major_gridlines': {'visible': False}})
spectral_density_chart.set_legend({'position': 'none'})
spectral_density_chart.set_size({'width': 640, 'height': 480})
return worksheet.insert_chart('D2', spectral_density_chart)
def chart_spectral_density_log(workbook, values_num):
worksheet = workbook.add_worksheet('SpectralDensityLog')
spectral_density_log_chart = workbook.add_chart({'type': 'scatter'})
spectral_density_log_chart.add_series({
'categories': ['SpectralDensity', 2, 0, values_num, 0],
'values': ['SpectralDensity', 2, 1, values_num, 1],
'marker': MARKER,
'trendline': {
'type': 'power',
'display_equation': True,
'display_r_squared': True}
})
spectral_density_log_chart.set_x_axis({'name': 'Frequency (log)',
'log_base': 10,
'major_unit': 0.1,
'minor_unit': 0.01,
'max': 0.5,
'position_axis': 'on_tick'})
spectral_density_log_chart.set_y_axis(
{'name': 'Spectral Density (log)', 'log_base': 10, 'num_format': '0.00E+00',
'major_gridlines': {'visible': False}})
spectral_density_log_chart.set_legend({'position': 'none'})
spectral_density_log_chart.set_size({'width': 640, 'height': 480})
return worksheet.insert_chart('D2', spectral_density_log_chart)