def __init__(self): self.X = np.linspace(0, 4 * np.pi, 200) self.pt = Plotter(1, 2, width=700, height=500, useAgg=True) self.pt.set_xlabel("X") self.pt.use_grid() self.pt.add_annotation(0, "First") self.pt.add_annotation(199, "Last")
def __init__(self): """ Constructs a Yampex Plotter object for a figure with two subplots. """ self.pt = Plotter(2, width=self.width, height=self.height) self.pt.use_grid() self.pt.set_title("Exponentials plotted from {:.1f} to {:.1f}", self.xMin, self.xMax) self.pt.set_xlabel("X") self.pt.set_ylabel("a*exp(-b*X)")
def __init__(self): """ Constructs a Yampex Plotter object for a figure with two subplots. """ self.mList = [] # Small MOSFET in an IC self.mList.append(MOSFET(2.5e-9, 5e17)) # High-current Power MOSFET self.mList.append(MOSFET(4e-9, 2.7e19)) # Plotter self.N_sp = len(self.mList) self.pt = Plotter(self.N_sp, width=self.width, height=self.height) self.pt.use_grid() self.pt.set_xlabel("Vgst") self.pt.set_ylabel("Vdsp") self.pt.add_legend("Vgst/n") self.pt.add_legend("(Vgst-f(x))/n") self.pt.use_labels()
# Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an "AS # IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language # governing permissions and limitations under the License. """ A log plot, with several plots in one subplot, all done in one call to the subplotting tool in context. """ import numpy as np from yampex import Plotter # Construct a Plotter object for a 1000x800 pixel (100 DPI) figure # with a single subplot. pt = Plotter(1, width=10.0, height=8.0) # The plots will be of different bases raised to powers. X = np.linspace(0, 10, 100) pt.set_title("Different Bases Raised to Power 0-10") # The x label will say "Power" and the subplot will have a grid. pt.set_xlabel("Power") pt.use_grid() # Make a subplotting context and work with the single subplot via the # subplot tool sp. It's actually just a reference to pt, but set up # for subplotting. with pt as sp: # Compute the vectors all at once Y2 = np.power(2, X) Y3 = np.power(3, X) Y10 = np.power(10, X)
# Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an "AS # IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language # governing permissions and limitations under the License. """ A sine and cosine plot in each of two subplots, with a call to the L{SpecialAx} object. """ import numpy as np from yampex import Plotter # Construct a Plotter object for a 700x500 pixel (100 DPI) figure with # two subplots. pt = Plotter(1, 2, width=7.0, height=5.0) # The plots, one in each subplot, will be of a sine and cosine with # 200 points from 0 to 4*pi. funcNames = ('sin', 'cos') X = np.linspace(0, 4 * np.pi, 200) pt.set_title("Sine and Cosine") # Each subplot will have an x-axis label of "X" and a grid. pt.set_xlabel("X") pt.use_grid() # Each plot will have an annotation labeled "Last" at its last # point. Note that we can use negative indices referenced to the last # element, just as with Python sequences. pt.add_annotation(-1, "Last") # Make a subplotting context and work with the two subplots via the # subplot tool sp. It's actually just a reference to pt, but set up
def __init__(self): """ Constructs a Yampex Plotter object for a figure with two subplots. """ self.pt = Plotter(2, width=self.width, height=self.height) self.pt.use_grid()
Illustrates the use of L{options.OptsBase.use_timex} and calls to a subplot-context instance of L{plot.Plotter} with multiple y-axis arguments. Also shows a couple of intelligently-positioned annotations. """ import numpy as np from yampex import Plotter EQs = ("sin(10*t)*cos(10000*t)", "cos(10*t)*cos(10000*t)") N = 6 t = np.linspace(0, 2E-6, 1000) # This time, we specify the plot dimensions in pixels with a tuple pt = Plotter(N, figSize=(1600, 1200)) pt.set_title("With {:d} time scales: {}, {}", N, *EQs) pt.use_timex() pt.use_grid() for eq in EQs: pt.add_legend(eq) with pt as sp: for mult in range(N): X = t * 10**mult Y1 = np.sin(10 * X) * np.sin(10000 * X) Y2 = np.cos(10 * X) * np.cos(10000 * X) sp.set_title("0 - {:.5g} seconds", X[-1]) if mult < 5 and np.any(Y2 < 0): sp.add_annotation(0.0, "Zero Crossing", kVector=1, y=True) sp(X, Y1, Y2) pt.show()
Illustrates the use of L{options.OptsBase.use_timex} and calls to a subplot-context instance of L{plot.Plotter} with multiple y-axis arguments. Also illustrates how simply a row can be made twice as high as the others. """ import numpy as np from yampex import Plotter N_sp = 4 N_pts = 200 X = np.linspace(0, 4 * np.pi, N_pts) pt = Plotter(1, 4, width=10, height=10, h2=0) pt.set_title("Sin(X) with increasingly noisy versions") pt.set_zeroLine() with pt as sp: Y = None for mult in np.logspace(-1.5, +0.5, N_sp): if Y is None: sp.add_textBox("SW", "This subplot is twice as high as the others.") Y = np.sin(X) Y_noisy = Y + mult * np.random.randn(N_pts) k = np.argmax(np.abs(Y - Y_noisy)) sp.add_textBox("NE", "Worst: {:+.3g} vs. {:+.3g}", Y_noisy[k], Y[k]) ax = sp(X, Y) ax.plot(X, Y_noisy, 'r.') pt.show()
def vectors(N): """ Returns a list with X and C{k*sin(k*X)} for I{k} from 1 to I{N}, where X is a 1-D Numpy vector having 200 points from 0 to M{4*pi}. """ X = np.linspace(0, 4 * np.pi, 200) return [X] + [k * np.sin(k * X) for k in range(1, N + 1)] # The number of waveforms N = 3 # Construct a Plotter object for a 800x500 pixel (specified directly # in pixels) figure with a single subplot. pt = Plotter(1, width=800, height=500) # As with many methods of opts.OptsBase, you can specify the title # with a string formatting prototype and its argument(s). pt.set_title("Sine Waves with {:d} frequency & amplitude multipliers", N) # The x label will say "X" and the subplot will have a grid. pt.set_xlabel("X") pt.use_grid() # Make a subplotting context and work with the single subplot via the # subplot tool sp. It's actually just a reference to pt, but set up # for subplotting. with pt as sp: # Add legends for the plots. Again, a string formatting prototype # and its argument are used for convenience. for mult in range(1, N + 1): sp.add_legend("x{:d}", mult)