コード例 #1
0
ファイル: laser_interactive.py プロジェクト: Padraic-M/laser
    plot_widget.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
    plot_widget._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

# Create the sliders for the length and reflectivity parameters.
length = Slider(axes_length, "Cavity length", 0.01, 1, valinit=L)
reflect = Slider(axes_reflect, "Reflectivity", 0.1, 1, valinit=R)

# Create a callback function for the slider controls
def update(val):
    # Replot the graph using the new values
    R = reflect.val
    L = length.val
    T = np.sqrt(1.0 - R ** 2)
    D = T ** 4 + 4 * R ** 2 * np.sin(2 * np.pi * (w + w_hene) / c * L) ** 2
    I = T ** 4 / D
    plt.set_ydata(F * I * 1e6)

    # Render the result on the canvas
    fig.canvas.draw()


# Assign the callback function to the sliders
length.on_changed(update)
reflect.on_changed(update)

# Either show via PyLab or enter the Tk loop
if use_mpl:
    tk.mainloop()
else:
    pl.show()
コード例 #2
0
ファイル: histogram3.py プロジェクト: rpruim/GeneZoom
ax1.grid(True)
plt.title("Frequency of %s" %column)
plt.ylabel('Frequency')
ax1.axes.get_xaxis().set_visible(False)
ax2=fig.add_axes(rugRect, axisbg=axescolor, sharex=ax1)
zeros=[0]*hist.length()
ax2.axes.get_yaxis().set_visible(False)
plt.xlabel(column)

#draw the initial histograms
ax1.hist(hist.data, facecolor='green', alpha=0.75, align='mid', range=(hist.min, hist.max), rwidth=1)
ax2.plot(hist.data, zeros, "|")

#if an alteration in the requested slider values occurs, then create the new histogram based on these values
def update(val):
    ax1.clear()
    ax2.clear()
    xLoc = sLoc.val
    xWidth = sZoom.val
    leftValue=xLoc-(xWidth/2)
    rightValue=xLoc+(xWidth/2)
    ax1.hist(hist.data, facecolor='green', alpha=0.75, align='mid', range=(leftValue, rightValue), rwidth=1)
    ax2.plot(hist.data, zeros, "|")
    draw()
sLoc.on_changed(update)
sZoom.on_changed(update)

show()
#save to a pdf file
fig.savefig('Example Histogram-Frequency of %s.pdf' % column)