9 examples of 'matplotlib x limits' in Python

Every line of 'matplotlib x limits' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
638def set_limits(self, xlim=None, ylim=None, ax=None):
639 """
640 Set the display limits.
641
642 Parameters
643 ----------
644 xlim : tuple, optional
645 2-Tuple containing y-axis limits in km. None uses default limits.
646 ylim : tuple, optional
647 2-Tuple containing x-axis limits in km. None uses default limits.
648 ax : Axis
649 Axis to adjust. None will adjust the current axis.
650
651 """
652 if ax is None:
653 ax = plt.gca()
654 if ylim is not None:
655 ax.set_ylim(ylim)
656 if xlim is not None:
657 ax.set_xlim(xlim)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

47def set_xlim(self, xlim):
48 """
49 Sets the range of space that is plotted in the graph.
50
51 Parameters
52 ----------
53 xlim : tuple
54 The range (xmin, xmax)
55 """
56 # x coordinate of center of leftmost pixel
57 self.xmin = xlim[0]
58 # x coordinate of center of rightmost pixel
59 self.xmax = xlim[1]
60 self.delta_x = (self.xmax-self.xmin)/float(self.cols-1)
280def setXRange(self, lower, upper):
281 """Set the X Axis to extend from lower to upper"""
282 self.pw.getPlotItem().getViewBox().setXRange(lower, upper)
104def 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
372def set_axis_labels ( self , x ) :
373 pass
405def setLimits(self, xmin, xmax, ymin, ymax, y2min=None, y2max=None):
406 """Set the limits of the X and Y axes at once.
407
408 :param float xmin: minimum bottom axis value
409 :param float xmax: maximum bottom axis value
410 :param float ymin: minimum left axis value
411 :param float ymax: maximum left axis value
412 :param float y2min: minimum right axis value
413 :param float y2max: maximum right axis value
414 """
415 self.__xLimits = xmin, xmax
416 self.__yLimits['left'] = ymin, ymax
417 if y2min is not None and y2max is not None:
418 self.__yLimits['right'] = y2min, y2max
167def get_limits(self,axisId,figureId):
168 '''
169 Return axis limits.
170 '''
171 ax = self.mainFigureTemplates[figureId][axisId]['ax']
172 xLim = ax.get_xlim()
173 yLim = ax.get_ylim()
174 return [xLim,yLim]
47def xmin(self):
48 """
49 sage: G = Graphics3d(); G
50 3d Graphics object consisting of 0 graphics primitives:
51 sage: G.xmin()
52 0
53 """
54 return self.__xmin
23def _setup_axis(self, xmin, xmax, ymin, ymax):
24 self.y_axis = OrderedDict()
25 self.x_axis = OrderedDict()
26 for pos, y in enumerate(frange(ymin, ymax, (ymax-ymin)/float(self.size))):
27 self.y_axis[y] = pos
28 for pos, x in enumerate(frange(xmin, xmax, (xmax-xmin)/float(self.size))):
29 self.x_axis[x] = self.size- 1 - pos

Related snippets