Every line of 'plotly add title' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
104 def setup_axis(X, Y, ax=None, fig=None, ylims=None): 105 """Setup axis, including timer for animation or snaps 106 107 Parameters 108 ---------- 109 X : 110 space disctretization to get limits 111 Y : 112 solution to get limits 113 ax : 114 ax where to put everything, if None current axes are used (Default value = None) 115 fig : 116 fig where to put everything, if None current figure is used (Default value = None) 117 ylims : 118 custom ylims, if None y axis limits are calculated from Y (Default value = None) 119 120 Returns 121 ------- 122 ax 123 124 fig 125 126 time_text 127 object to fill in text 128 129 """ 130 if ax is None: 131 fig = plt.gcf() 132 ax = plt.gca() 133 if ylims is None: 134 lowery = nm.min(Y) - nm.min(Y) / 10 135 uppery = nm.max(Y) + nm.max(Y) / 10 136 else: 137 lowery = ylims[0] 138 uppery = ylims[1] 139 ax.set_ylim(lowery, uppery) 140 ax.set_xlim(X[0], X[-1]) 141 time_text = ax.text(X[0] + nm.sign(X[0]) * X[0] / 10, 142 uppery - uppery / 10, 143 'empty', fontsize=15) 144 return ax, fig, time_text