MCPcopy
hub / github.com/vnpy/vnpy / add_plot

Method add_plot

vnpy/chart/widget.py:62–112  ·  view source on GitHub ↗

Add plot area.

(
        self,
        plot_name: str,
        minimum_height: int = 80,
        maximum_height: int | None = None,
        hide_x_axis: bool = False
    )

Source from the content-addressed store, hash-verified

60 self, self._manager, self._plots, self._item_plot_map)
61
62 def add_plot(
63 self,
64 plot_name: str,
65 minimum_height: int = 80,
66 maximum_height: int | None = None,
67 hide_x_axis: bool = False
68 ) -> None:
69 """
70 Add plot area.
71 """
72 # Create plot object
73 plot: pg.PlotItem = pg.PlotItem(axisItems={"bottom": self._get_new_x_axis()})
74 plot.setMenuEnabled(False)
75 plot.setClipToView(True)
76 plot.hideAxis("left")
77 plot.showAxis("right")
78 plot.setDownsampling(mode="peak")
79 plot.setRange(xRange=(0, 1), yRange=(0, 1))
80 plot.hideButtons()
81 plot.setMinimumHeight(minimum_height)
82
83 if maximum_height:
84 plot.setMaximumHeight(maximum_height)
85
86 if hide_x_axis:
87 plot.hideAxis("bottom")
88
89 if not self._first_plot:
90 self._first_plot = plot
91
92 # Connect view change signal to update y range function
93 view: pg.ViewBox = plot.getViewBox()
94 view.sigXRangeChanged.connect(self._update_y_range)
95 view.setMouseEnabled(x=True, y=False)
96
97 # Set right axis
98 right_axis: pg.AxisItem = plot.getAxis("right")
99 right_axis.setWidth(60)
100 right_axis.tickFont = NORMAL_FONT
101
102 # Connect x-axis link
103 if self._plots:
104 first_plot: pg.PlotItem = list(self._plots.values())[0]
105 plot.setXLink(first_plot)
106
107 # Store plot object in dict
108 self._plots[plot_name] = plot
109
110 # Add plot onto the layout
111 self._layout.nextRow()
112 self._layout.addItem(plot)
113
114 def add_item(
115 self,

Callers 1

run.pyFile · 0.80

Calls 2

_get_new_x_axisMethod · 0.95
connectMethod · 0.45

Tested by

no test coverage detected