seolpyo-mplchart 0.1.3.4__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of seolpyo-mplchart might be problematic. Click here for more details.

@@ -1,63 +1,107 @@
1
- """
2
- This software includes Matplotlib, which is licensed under the BSD License.
3
- Matplotlib Copyright (c) 2012- Matplotlib Development Team.
4
- Full license can be found in the LICENSE file or at https://matplotlib.org/stable/users/license.html
5
- """
6
-
7
-
8
1
  import json
9
- from pathlib import Path
10
2
  from typing import Literal
3
+ from pathlib import Path
11
4
 
12
5
  import matplotlib.pyplot as plt
13
- from matplotlib.figure import Figure
14
6
  import pandas as pd
15
7
 
16
-
17
- from .slider import Chart as CM
8
+ from .draw import Chart as BaseChart
9
+ from .cursor import Chart as BaseCursorChart, format_candleinfo_ko, format_volumeinfo_ko, format_candleinfo_en, format_volumeinfo_en
10
+ from .slider import Chart as BaseSliderChart
18
11
 
19
12
 
20
13
  __all__ = [
21
- 'pd',
22
- 'plt',
14
+ 'path_samsung', 'path_apple',
15
+ 'format_candleinfo_ko', 'format_volumeinfo_ko',
16
+ 'format_candleinfo_en', 'format_volumeinfo_en',
17
+ 'sample', 'switch_backend', 'show', 'close',
18
+ 'Chart', 'CursorChart', 'SliderChart',
19
+ ]
23
20
 
24
- 'Chart',
25
21
 
26
- 'sample',
27
- 'show',
28
- 'close',
29
- ]
22
+ path_samsung = Path(__file__).parent / 'sample/samsung.txt'
23
+ path_apple = Path(__file__).parent / 'sample/apple.txt'
24
+
25
+ def sample(stock: Literal['samsung', 'apple']='samsung', chart: Literal['Chart', 'CursorChart', 'SliderChart']='SliderChart'):
26
+ C: BaseSliderChart = {'Chart': BaseChart, 'CursorChart': BaseCursorChart, 'SliderChart': BaseSliderChart}[chart]()
27
+ path_file = path_samsung if stock == 'samsung' else path_apple
28
+ if stock == 'samsung':
29
+ C.format_candleinfo = format_candleinfo_ko
30
+ C.format_volumeinfo = format_volumeinfo_ko
31
+ else:
32
+ C.format_candleinfo = format_candleinfo_en
33
+ C.format_volumeinfo = format_volumeinfo_en
34
+ C.unit_price = '$'
35
+ C.unit_volume = 'Vol'
36
+ C.digit_price = 3
37
+ C.format_ma = 'ma{}'
38
+
39
+ with open(path_file, 'r', encoding='utf-8') as txt:
40
+ data = json.load(txt)
41
+ df = pd.DataFrame(data)
42
+
43
+ C.set_data(df)
44
+
45
+ show()
46
+ close()
47
+ return
48
+
49
+
50
+ def switch_backend(newbackend='TkAgg'):
51
+ "call matplotlib.pyplot.switch_backend(newbackend)"
52
+ return plt.switch_backend(newbackend)
53
+
54
+
55
+ def show(Close=False):
56
+ """
57
+ call matplotlib.pyplot.show()
58
+ ```if Close``` if True, run matplotlib.pyplot.close('all') after window closee.
59
+ """
60
+ plt.show()
61
+ if Close: close()
62
+ return
63
+
64
+
65
+ def close(fig='all'):
66
+ "call matplotlib.pyplot.close(fig)"
67
+ return plt.close(fig)
30
68
 
31
69
 
32
- class Chart(CM):
70
+ class Chart(BaseChart):
33
71
  r"""
34
72
  You can see the guidance document:
35
73
  Korean: https://white.seolpyo.com/entry/147/
36
74
  English: https://white.seolpyo.com/entry/148/
37
75
 
38
- Variables:
39
- unit_price, unit_volume: unit for price and volume. default ('원', '주').
76
+ Quick Start:
77
+ ```
78
+ import seolpyo_mplchart as mc
79
+ chart = mc.SliderChart() # Create instance
80
+ chart.set_data(df) # set stock price data
81
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
82
+ mc.close() # run ```matplotlib.pyplot.close('close')```
83
+ ```
84
+
85
+ Class Variables:
86
+ watermark: watermark text.
40
87
 
41
- figsize: figure size if you use plt.show(). default (12, 6).
42
- ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio. default (3, 2, 18, 5).
43
- adjust: figure adjust. default dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0).
44
- slider_top: ax_slider is located at the top or bottom. default True.
88
+ figsize: Default size when creating a matplotlib window
89
+ ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
90
+ adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
45
91
  color_background: color of background. default '#fafafa'.
46
- color_grid: color of grid. default '#d0d0d0'.
92
+ gridKwargs: kwargs applied to the grid
93
+ color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
47
94
 
48
- df: stock data.
95
+ df: stock data DataFrame.
49
96
  date: date column key. default 'date'
50
97
  Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
51
- volume: volume column key. default 'volume'
98
+ volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
52
99
 
53
- label_ma: moving average legend label format. default '{}일선'
100
+ format_ma: moving average legend label format. default '{}일선'
54
101
  list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
55
- list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied. default ('darkred', 'fuchsia', 'olive', 'orange', 'navy', 'darkmagenta', 'limegreen', 'darkcyan',)
102
+ list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
56
103
 
57
- candle_on_ma: Decide whether to draw candles on the moving average line. default True
58
- color_sliderline: Color of closing price line in ax_slider. default 'k'
59
- color_navigatorline: Color of left and right dividing lines in selected area. default '#1e78ff'
60
- color_navigator: Color of unselected area. default 'k'
104
+ candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
61
105
 
62
106
  color_up: The color of the candle. When the closing price is greater than the opening price. default '#fe3032'
63
107
  color_down: The color of the candle. When the opening price is greater than the opening price. default '#0095ff'
@@ -66,55 +110,162 @@ class Chart(CM):
66
110
  color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day. default 'w'
67
111
  colors_volume: The color of the volume bar. default '#1f77b4'
68
112
 
69
- lineKwargs: Options applied to horizontal and vertical lines drawn along the mouse position. default dict(edgecolor='k', linewidth=1, linestyle='-')
70
- textboxKwargs: Options that apply to the information text box. dufault dict(boxstyle='round', facecolor='w')
113
+ color_priceline: The color of the price line. default 'k'
114
+
115
+ facecolor_volume, edgecolor_volume = The color of the volume. default ('#1f77b4', 'k')
116
+
117
+ candle_width_half, volume_width_half: half of the thickness of the candle and volume
118
+
119
+ color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
120
+
121
+ limit_candle: Maximum number of candles to draw. default 800
122
+ limit_wick: Maximum number of candle wicks to draw. default 4,000
123
+ """
124
+ pass
125
+
126
+
127
+ class CursorChart(BaseCursorChart):
128
+ r"""
129
+ You can see the guidance document:
130
+ Korean: https://white.seolpyo.com/entry/147/
131
+ English: https://white.seolpyo.com/entry/148/
132
+
133
+ Quick Start:
134
+ ```
135
+ import seolpyo_mplchart as mc
136
+ chart = mc.SliderChart() # Create instance
137
+ chart.set_data(df) # set stock price data
138
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
139
+ mc.close() # run ```matplotlib.pyplot.close('close')```
140
+ ```
141
+
142
+ Class Variables:
143
+ watermark: watermark text.
144
+
145
+ unit_price, unit_volume: price and volume unit. default ('원', '주').
146
+ digit_price, digit_volume: display decimal places when displaying price and volume. default (0, 0),
147
+
148
+ figsize: Default size when creating a matplotlib window
149
+ ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
150
+ adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
151
+ color_background: color of background. default '#fafafa'.
152
+ gridKwargs: kwargs applied to the grid
153
+ color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
154
+
155
+ df: stock data DataFrame.
156
+ date: date column key. default 'date'
157
+ Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
158
+ volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
159
+
160
+ format_ma: moving average legend label format. default '{}일선'
161
+ list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
162
+ list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
163
+
164
+ candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
165
+
166
+ color_up: The color of the candle. When the closing price is greater than the opening price. default '#fe3032'
167
+ color_down: The color of the candle. When the opening price is greater than the opening price. default '#0095ff'
168
+ color_flat: The color of the candle. WWhen the closing price is the same as the opening price. default 'k'
169
+ color_up_down: The color of the candle. If the closing price is greater than the opening price, but is lower than the previous day's closing price. default 'w'
170
+ color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day. default 'w'
171
+ colors_volume: The color of the volume bar. default '#1f77b4'
172
+
173
+ color_priceline: The color of the price line. default 'k'
174
+
175
+ facecolor_volume, edgecolor_volume = The color of the volume. default ('#1f77b4', 'k')
176
+
177
+ candle_width_half, volume_width_half: half of the thickness of the candle and volume
178
+
179
+ color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
180
+
181
+ lineKwargs: kwarg applied to lines drawn based on mouse cursor position
182
+ textboxKwargs: kwarg applied to the info text bbox drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
183
+ textKwargs: A kwarg that applies to the informational text drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
71
184
 
72
185
  fraction: Decide whether to express information as a fraction. default False
73
- candleformat: Candle information text format. default '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
74
- volumeformat: Volume information text format. default '{dt}\n\n거래량   : {volume}\n거래량증가율: {rate_volume}'
75
- digit_price, digit_volume: Number of decimal places expressed in informational text. default (0, 0)
186
+ format_candleinfo: Candle information text format. default '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
187
+ format_volumeinfo: Volume information text format. default '{dt}\n\n거래량   : {volume}\n거래량증가율: {rate_volume}'
76
188
 
77
- min_distance: Minimum number of candles that can be selected with the slider. default 30
78
- simpler: Decide whether to display candles simply when moving the chart. default False
79
- limit_volume: Maximum number of volume bars drawn when moving the chart. default 2_000
189
+ limit_candle: Maximum number of candles to draw. default 800
190
+ limit_wick: Maximum number of candle wicks to draw. default 4,000
80
191
  """
81
192
  pass
82
193
 
83
194
 
84
- _name = {'samsung', 'apple'}
85
- def sample(name: Literal['samsung', 'apple']='samsung'):
86
- if name not in _name:
87
- print('name should be either samsung or apple.')
88
- return
89
- file = Path(__file__).parent / f'data/{name}.txt'
90
- with open(file, 'r', encoding='utf-8') as txt:
91
- data = json.load(txt)
92
- data = data
93
- df = pd.DataFrame(data)
195
+ class SliderChart(BaseSliderChart):
196
+ r"""
197
+ You can see the guidance document:
198
+ Korean: https://white.seolpyo.com/entry/147/
199
+ English: https://white.seolpyo.com/entry/148/
94
200
 
95
- c = Chart()
96
- if name == 'apple':
97
- c.unit_price = '$'
98
- c.unit_volume = ' vol'
99
- c.digit_price = 3
100
- c.label_ma = 'ma{}'
101
- c.candleformat = '{}\n\nend: {}\nrate: {}\ncompare: {}\nopen: {}({})\nhigh: {}({})\nlow: {}({})\nvolume: {}({})'
102
- c.volumeformat = '{}\n\nvolume: {}\nvolume rate: {}'
103
- c.set_data(df)
104
- show()
105
- close()
106
- return
201
+ Quick Start:
202
+ ```
203
+ import seolpyo_mplchart as mc
204
+ chart = mc.SliderChart() # Create instance
205
+ chart.set_data(df) # set stock price data
206
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
207
+ mc.close() # run ```matplotlib.pyplot.close('close')```
208
+ ```
107
209
 
210
+ Class Variables:
211
+ watermark: watermark text.
108
212
 
109
- def show():
110
- return plt.show()
213
+ unit_price, unit_volume: price and volume unit. default ('원', '주').
214
+ digit_price, digit_volume: display decimal places when displaying price and volume. default (0, 0),
111
215
 
216
+ figsize: Default size when creating a matplotlib window
217
+ slider_top: ax_slider is located at the top or bottom. default ```True```.
218
+ ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
219
+ ratio_ax_none: Ratio between volume chart and slider. Used only when slider_top is ```False```
220
+ adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
221
+ color_background: color of background. default '#fafafa'.
222
+ gridKwargs: kwargs applied to the grid
223
+ color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
112
224
 
113
- def close(fig: int|str|Figure|None='all'):
114
- return plt.close(fig)
225
+ df: stock data DataFrame.
226
+ date: date column key. default 'date'
227
+ Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
228
+ volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
229
+
230
+ format_ma: moving average legend label format. default '{}일선'
231
+ list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
232
+ list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
233
+
234
+ candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
235
+ color_sliderline: Color of closing price line in ax_slider. default 'k'
236
+ color_navigatorline: Color of left and right dividing lines in selected area. default '#1e78ff'
237
+ color_navigator: Color of unselected area. default 'k'
238
+
239
+ color_up: The color of the candle. When the closing price is greater than the opening price. default '#fe3032'
240
+ color_down: The color of the candle. When the opening price is greater than the opening price. default '#0095ff'
241
+ color_flat: The color of the candle. WWhen the closing price is the same as the opening price. default 'k'
242
+ color_up_down: The color of the candle. If the closing price is greater than the opening price, but is lower than the previous day's closing price. default 'w'
243
+ color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day. default 'w'
244
+ colors_volume: The color of the volume bar. default '#1f77b4'
245
+
246
+ color_priceline: The color of the price line. default 'k'
115
247
 
248
+ facecolor_volume, edgecolor_volume = The color of the volume. default ('#1f77b4', 'k')
116
249
 
117
- if __name__ == '__main__':
118
- sample('apple')
250
+ candle_width_half, volume_width_half: half of the thickness of the candle and volume
119
251
 
252
+ color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
120
253
 
254
+ lineKwargs: kwarg applied to lines drawn based on mouse cursor position
255
+ textboxKwargs: kwarg applied to the info text bbox drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
256
+ textKwargs: A kwarg that applies to the informational text drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
257
+
258
+ fraction: Decide whether to express information as a fraction. default False
259
+ format_candleinfo: Candle information text format. default '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
260
+ format_volumeinfo: Volume information text format. default '{dt}\n\n거래량   : {volume}\n거래량증가율: {rate_volume}'
261
+
262
+ min_distance: Minimum number of candles that can be selected with the slider. default 30
263
+ limit_candle: Maximum number of candles to draw. default 800
264
+ limit_wick: Maximum number of candle wicks to draw. default 4,000
265
+ limit_volume: Maximum number of volume bars to draw. default 800. Applies only to drawing candle wicks or price line.
266
+ limit_ma: If the number of displayed data is more than this, the price moving average line is not drawn. default 8,000
267
+
268
+ color_navigator_line: Navigator divider color. default '#1e78ff'
269
+ color_navigator_cover: Unselected slider area color. default = 'k'
270
+ """
271
+ pass
seolpyo_mplchart/base.py CHANGED
@@ -1,10 +1,13 @@
1
+ from re import search
2
+
1
3
  import matplotlib.pyplot as plt
2
4
  import matplotlib.style as mplstyle
3
5
  from matplotlib.axes import Axes
4
6
  from matplotlib.backends.backend_agg import FigureCanvasAgg
7
+ from matplotlib.figure import Figure as Fig
5
8
 
6
9
 
7
- from .utils import convert_unit
10
+ from .utils import dict_unit, dict_unit_en
8
11
 
9
12
 
10
13
  try: plt.switch_backend('TkAgg')
@@ -17,95 +20,95 @@ except: pass
17
20
  mplstyle.use('fast')
18
21
 
19
22
 
20
- class Base:
23
+ def convert_unit(value: float, digit=0, word='원'):
24
+ v = value.__abs__()
25
+ du = dict_unit if search('[가-힣]', word) else dict_unit_en
26
+ for unit, n in du.items():
27
+ if n <= v:
28
+ num = (value / n).__round__(digit)
29
+ if not num % 1: num = int(num)
30
+ return f'{num:,}{unit} {word}'
31
+ value = value.__round__(digit)
32
+ if not value % 1: value = int(value)
33
+ elif value < 10: digit = 2
34
+ text = f'{value:,}{word}'
35
+ return text
36
+
37
+
38
+ class Figure(Fig):
21
39
  canvas: FigureCanvasAgg
22
- unit_price, unit_volume = ('원', '주')
23
40
 
24
- figsize = (12, 6)
25
- ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume = (3, 2, 18, 5)
41
+
42
+ class Base:
43
+ figure: Figure
44
+
45
+ figsize = (14, 7)
46
+ ratio_ax_legend, ratio_ax_price, ratio_ax_volume = (2, 18, 5)
26
47
  adjust = dict(
27
48
  top=0.95, bottom=0.05, left=0.01, right=0.93, # 여백
28
49
  wspace=0, hspace=0 # 플롯간 간격
29
50
  )
30
- color_grid = '#d0d0d0'
31
- color_background = '#fafafa'
32
51
 
33
- slider_top = True
34
52
  title = 'seolpyo mplchart'
53
+ color_background = '#fafafa'
54
+ gridKwargs = {}
55
+ color_tick, color_tick_label = ('k', 'k')
56
+
57
+ unit_price, unit_volume = ('원', '주')
35
58
 
36
59
  def __init__(self, *args, **kwargs):
37
60
  # 기본 툴바 비활성화
38
61
  plt.rcParams['toolbar'] = 'None'
62
+ # plt.rcParams['figure.dpi'] = 600
39
63
 
40
- self._set_plot()
64
+ self._get_plot()
41
65
  return
42
66
 
43
- def _set_plot(self):
44
- if self.slider_top:
45
- fig, ax = plt.subplots(
46
- 4, # row
47
- figsize=self.figsize, # 기본 크기
48
- height_ratios=(self.ratio_ax_slider, self.ratio_ax_legend, self.ratio_ax_price, self.ratio_ax_volume) # row 크기 비율
49
- )
50
- ax: list[Axes]
51
- ax_slider, ax_legend, ax_price, ax_volume = ax
52
- else:
53
- fig, ax = plt.subplots(
54
- 5, # row 수
55
- figsize=self.figsize, # 기본 크기
56
- height_ratios=(self.ratio_ax_legend, self.ratio_ax_price, self.ratio_ax_volume, self.ratio_ax_legend, self.ratio_ax_slider) # row 크기 비율
57
- )
58
- ax: list[Axes]
59
- ax_legend, ax_price, ax_volume, ax_none, ax_slider = ax
60
- # 사용하지 않는 axes 숨기기
61
- ax_none.axis('off')
62
- ax_legend.axis('off')
63
-
64
- ax_slider.xaxis.set_animated(True)
65
- ax_slider.yaxis.set_animated(True)
66
-
67
- ax_price.xaxis.set_animated(True)
68
- ax_price.yaxis.set_animated(True)
69
-
70
- ax_volume.xaxis.set_animated(True)
71
- ax_volume.yaxis.set_animated(True)
72
-
73
- fig.canvas.manager.set_window_title(f'{self.title}')
67
+ def _get_plot(self):
68
+ self.figure, axes = plt.subplots(
69
+ 3, # row
70
+ figsize=self.figsize, # 기본 크기
71
+ height_ratios=(self.ratio_ax_legend, self.ratio_ax_price, self.ratio_ax_volume) # row 크기 비율
72
+ )
73
+ axes: list[Axes]
74
+ self.ax_legend, self.ax_price, self.ax_volume = axes
75
+ self.ax_legend.set_label('legend ax')
76
+ self.ax_price.set_label('price ax')
77
+ self.ax_volume.set_label('volume ax')
78
+
79
+ self.figure.canvas.manager.set_window_title(f'{self.title}')
80
+ self.figure.set_facecolor(self.color_background)
74
81
 
75
82
  # 플롯간 간격 제거(Configure subplots)
76
- fig.subplots_adjust(**self.adjust)
83
+ self.figure.subplots_adjust(**self.adjust)
84
+
85
+ self.ax_legend.set_axis_off()
77
86
 
78
87
  # y ticklabel foramt 설정
79
- ax_slider.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_price))
80
- ax_price.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_price))
81
- ax_volume.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_volume))
88
+ self.ax_price.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_price, digit=2))
89
+ self.ax_volume.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_volume, digit=2))
82
90
 
91
+ gridKwargs = {'visible': True, 'linewidth': 1, 'color': '#d0d0d0', 'linestyle': '--'}
92
+ gridKwargs.update(self.gridKwargs)
83
93
  # 공통 설정
84
- for a in [ax_slider, ax_price, ax_volume]:
94
+ for ax in (self.ax_price, self.ax_volume):
95
+ ax.xaxis.set_animated(True)
96
+ ax.yaxis.set_animated(True)
97
+
98
+ # x tick 외부 눈금 표시하지 않기
99
+ ax.xaxis.set_ticks_position('none')
100
+ # x tick label 제거
101
+ ax.set_xticklabels([])
85
102
  # y tick 우측으로 이동
86
- a.tick_params(left=False, right=True, labelleft=False, labelright=True)
87
- # 차트 영역 배경 색상
88
- a.set_facecolor(self.color_background)
89
- # grid(구분선, 격자) 그리기
90
- a.grid(True, color=self.color_grid, linewidth=1)
91
- # x tick 제거
92
- a.set_xticklabels([])
93
-
94
- self.fig, self.canvas = (fig, fig.canvas)
95
- self.ax_slider, self.ax_legend, self.ax_price, self.ax_volume = (ax_slider, ax_legend, ax_price, ax_volume)
103
+ ax.tick_params(left=False, right=True, labelleft=False, labelright=True, colors=self.color_tick_label)
104
+ # Axes 외곽선 변경
105
+ for i in ['top', 'bottom', 'left', 'right']: ax.spines[i].set_color(self.color_tick)
96
106
 
97
- return self.set_plot()
107
+ # 차트 영역 배경 색상
108
+ ax.set_facecolor(self.color_background)
98
109
 
99
- def set_plot(self):
100
- "This function works after set plot process is done."
110
+ # grid(구분선, 격자) 그리기
111
+ # 어째서인지 grid의 zorder 값을 선언해도 1.6을 값으로 한다.
112
+ ax.grid(**gridKwargs)
101
113
  return
102
114
 
103
-
104
- class Chart(Base):
105
- pass
106
-
107
-
108
- if __name__ == '__main__':
109
- Base()
110
-
111
- plt.show()