本文整理汇总了Python中plot.Plot类的典型用法代码示例。如果您正苦于以下问题:Python Plot类的具体用法?Python Plot怎么用?Python Plot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_source
def set_source(self,source,nodes=None):
"""
Handles opening a new file. Creates a plot with the given source
file. Uses input plugins to convert file to SVG. This disregards
all previous settings, thus ui_updates should be called.
"""
height = self.material.length and self.material.length*UNITS[self.units] or None
p = Plot(width=self.material.width*UNITS[self.units],height=height,color=self.material.color)
m = self.material.margin
p.set_padding(top=m[0],right=m[1],bottom=m[2],left=m[3])
if type(source) == etree._ElementTree:
try:
# If certain nodes are selected, only plot them.
if nodes:
xml = etree.tostring(get_selected_nodes(source,nodes))
else:
xml = etree.tostring(source)
# Set a job name if none exists
if self.name is None:
self.name = "*inkscape.svg"
# Try to make a plot
p.set_graphic(xml)
self.plot = p
except (IOError,etree.XMLSyntaxError),trace:
log.debug(trace)
raise Exception("Failed to create plot. Reason: Failed to import the Inkscape file.")
示例2: plot_before
def plot_before (before, output_dir):
from chemotext_util import LoggingUtil
logger = LoggingUtil.init_logging (__file__)
if before.count () <= 0:
return
'''
before = before.reduceByKey (lambda x, y : x + y). \
mapValues (lambda x : filter (lambda v : v is not None, x))
'''
true_plots_dir = os.path.join (output_dir, "chart")
print ("-------------> before 0")
true_mentions = before. \
mapValues (lambda x : Plot.plot_true_mentions (x, true_plots_dir)). \
filter (lambda x : len(x[1]) > 0)
logger.info ("Plotted {0} sets of true mentions.".format (true_mentions.count ()))
print ("-------------> before 1")
false_plots_dir = os.path.join (output_dir, "chart", "false")
false_mentions = before.subtractByKey (true_mentions)
false_frequency = false_mentions. \
mapValues (lambda x : Plot.false_mention_histogram (x, false_plots_dir))
false_mentions = false_mentions. \
mapValues (lambda x : Plot.plot_false_mentions (x, false_plots_dir))
logger.info ("false mentions: {0}".format (false_mentions.count ()))
true_mentions = None
false_mentions = None
false_frequency = None
示例3: plot
def plot(self, x, y):
# assign two columns (x,y) for plot
nofrow, noffeature = self.data.shape
graph = Plot()
if self.__type == 'supervise' and x < (noffeature - 1) and y < (noffeature - 1):
graph.plotting(self.data[:, x], self.data[:, y], self.data[:, -1])
else:
print 'Invalid feature number'
示例4: TestPlotBasic
class TestPlotBasic(TestCase):
def setUp(self):
self.plot = Plot("star wars")
def test_init(self):
self.assertTrue(self.plot.name == "star wars")
self.assertTrue(len(self.plot.entities_at_time(0)) == 0)
self.assertTrue(len(self.plot.relations_at_time(0)) == 0)
示例5: __init__
def __init__( self, serial = None, *args ) :
"""TemperaturePlot constructor it add axis titles."""
Plot.__init__( self, *args )
self.curve.setTitle( self._tr('LHe level data') )
self.setAxisTitle( Qwt.QwtPlot.xBottom, self._tr('Time (min)') )
self.setAxisTitle( Qwt.QwtPlot.yLeft, self._tr('LHe level (mm)') )
self.serial = serial
示例6: main
def main():
imgSrc=os.listdir(c.test)
imagenes=[]
tmp=[]
for e in imgSrc:
img=Imagen(e).imagen
rects=f.detectCara(img)
im,key=opc.dibujarPuntos(img)
tmp.append((im,e))
plt=Plot()
plt.show(tmp,5)
示例7: plot_distances
def plot_distances (distances):
if distances.count () <= 0:
return
d = distances. \
map (lambda x : ( x[0], x[1], x[2], x[3] ) ). \
sample (False, 0.15). \
toDF().toPandas ()
d = d.rename (columns = { "_1" : "truth",
"_2" : "doc_dist",
"_3" : "par_dist",
"_4" : "sen_dist" })
Plot.plot_distances (d)
示例8: setAxisAutoScale
def setAxisAutoScale(self, axis, auto=True):
if axis != Qwt.QwtPlot.yRight:
Plot.setAxisAutoScale(self, axis, auto)
else:
if not hasattr(self, '_cmap'):
self._cmap = CmapJack()
if auto:
self.set_cbar(self._cmap, None)
else:
self.set_cbar(self._cmap, (self._axis_limits[axis][0],
self._axis_limits[axis][1]))
Plot.setAxisAutoScale(self, axis, auto)
示例9: Run
def Run(self):
try:
field = Field(self._length, self._springconst, self._deltaslope)
field.addTubes(self._count)
plot = Plot(self._length)
tubes = field.getTubes()
# Debugging code
start = []
stop =[]
for key in field.getTubes().keys():
if field.getTubes()[key].getParams()['P'][0] <= 0:
start.append(key),","
if field.getTubes()[key].getParams()['Q'][0] >= self._length:
stop.append(key)
print "Starting Tubes:",start
print "Stopping Tubes:",stop
print "------------------------------------------"
#time.sleep(10)
plot.plotField(tubes)
end = 0
while end < 1:
field.calculateIntercepts()
point_forces = field.getPointForces()
for key in field.getTubes().keys():
print key,":",field.getTubes()[key].getParams()['neighbors'].keys()
print "=================================="
traverses = 0
neighbor_dict = {}
roots = []
leaves = []
for index in tubes.keys():
neighbor_dict[index] = list()
neighbor_dict[index] = tubes[index].getParams()['neighbors'].keys()
if tubes[index].getParams()['P'][0] <= 0:
roots.append(index)
if tubes[index].getParams()['Q'][0] >= self._length:
leaves.append(index)
#print index
for index in roots:
traverses += field.traverseNeighbors(index,neighbor_dict,leaves,())
print traverses
#if end % 1 == 0:
#plot.plotField(tubes)
#field.rotateTubes(point_forces)
end += 1
except EquitubeException, e:
raise EquitubeException(e.get_message())
示例10: __init__
def __init__(self, parent):
Plot.__init__(self, parent)
# the plot and its data
self._raster_data = RasterData(self)
self._plot_item = Qwt.QwtPlotSpectrogram()
self._plot_item.setData(self._raster_data)
self._plot_item.attach(self)
# enable colormap and -bar
self._cbar = self.axisWidget(Qwt.QwtPlot.yRight)
self._cbar.setColorBarEnabled(True)
self.enableAxis(Qwt.QwtPlot.yRight)
self.set_cbar()
示例11: __init__
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
# create plots for drawing on
self.accel_plot = Plot(self, ylabel="Acceleration (g)", numy=3, xrng=10, name="ACCEL")
self.gyro_plot = Plot(self, ylabel="Angular Velocity (degrees/s)", numy=3, xrng=10, name="GYRO")
self.mag_plot = Plot(self, ylabel="Field Strength", numy=3, xrng=10, name="MAG")
self.plots = (self.accel_plot, self.gyro_plot, self.mag_plot)
self.attitude_plot = Tiltmeter(self)
self.x = 0
self.y = 0
self.width = 0
self.height = 0
self.plotnext = 0
示例12: set_up_plot
def set_up_plot(self, settings=None):
self.plot = Plot()
if settings is not None:
for key in settings:
self.plot.settings[key] = settings[key]
self.settings['plot'] = self.plot.settings
n_rows = self.plot.settings['n_rows']
n_cols = self.plot.settings['n_cols']
if n_rows is not None and n_cols is not None:
print '\nSetting up {0:d}x{1:d} plot.'.format(n_rows, n_cols)
else:
e_str = 'Number of {0:s} must be an integer > 0.'
n_rows, n_cols = (0, 0)
while n_rows < 1 or n_cols < 1:
n_rows = utils.get_input_integer( \
'\nNumber of subplot rows?\n> ',
error_text=e_str.format('rows'))[0]
n_cols = utils.get_input_integer( \
'Number of subplot columns?\n> ',
error_text=e_str.format('columns'))[0]
if n_rows < 1 or n_cols < 1:
print 'Must have > 0 rows and columns.'
self.plot.set_up_plot_grid(n_rows, n_cols)
#self.plot.plot_grid.tight_layout(self.plot.figure)
self.plot.figure.set_tight_layout(True)
plt.show(block=False)
print '(If you cannot see the plot, try changing the '
print 'matplotlib backend. Current backend is ' + \
plt.get_backend() + '.)'
示例13: processPage
def processPage(img):
print "Finding all possible rectangles in the page"
rects = findAllRects(img)
plotOuts = []
for rect in rects:
plot = Plot(img)
plot.corners = rect
try:
pout = processPlot(plot)
except:
pass
if pout != False:
plotOuts.append(pout)
return plotOuts
示例14: main
def main():
imgSrc=os.listdir(c.test)
imagenes=[]
total=0
detectadas=0
for e in imgSrc:
total+=1
im,todo=f.detectFace(Imagen(e).imagen,e)
if todo:
detectadas+=1
tmp=Imagen(im,name=e)
imagenes.append(tmp)
plt=Plot()
tmp=[]
print "total caras = "+str(total)+" todo detectado = "+str(detectadas)
for e in imagenes:
tmp.append((e.imagen,e.name))
plt.show(tmp,5)
示例15: init_ui
def init_ui(self):
self.init_radio()
self.acceleration_input.setText("9.8")
self.l1_input.setText("1.0")
self.l2_input.setText("1.0")
self.m1_input.setText("1.0")
self.m2_input.setText("1.0")
self.alpha_input.setText("120.0")
self.beta_input.setText("-10.0")
self.acceleration_input.textChanged[str].connect(self.change_argument)
self.l1_input.textChanged[str].connect(self.change_argument)
self.l2_input.textChanged[str].connect(self.change_argument)
self.m1_input.textChanged[str].connect(self.change_argument)
self.m2_input.textChanged[str].connect(self.change_argument)
self.alpha_input.textChanged[str].connect(self.change_argument)
self.beta_input.textChanged[str].connect(self.change_argument)
self.update_button.clicked.connect(self.update_animation)
layout = QtGui.QVBoxLayout(self)
splitter1 = QtGui.QSplitter(Qt.Vertical)
splitter1.addWidget(self.lbl1)
splitter1.addWidget(self.acceleration_input)
splitter1.addWidget(self.lbl2)
splitter1.addWidget(self.l1_input)
splitter1.addWidget(self.lbl3)
splitter1.addWidget(self.l2_input)
splitter1.addWidget(self.lbl4)
splitter1.addWidget(self.m1_input)
splitter1.addWidget(self.lbl5)
splitter1.addWidget(self.m2_input)
splitter1.addWidget(self.lbl7)
splitter1.addWidget(self.alpha_input)
splitter1.addWidget(self.lbl8)
splitter1.addWidget(self.beta_input)
splitter1.addWidget(self.lbl6)
splitter1.addWidget(self.r0)
splitter1.addWidget(self.r1)
splitter1.addWidget(self.r2)
splitter1.addWidget(self.r3)
splitter1.addWidget(self.update_button)
# splitter1.addWidget(left)
splitter0 = QtGui.QSplitter(Qt.Horizontal)
splitter0.addWidget(splitter1)
splitter2 = QtGui.QSplitter(Qt.Vertical)
splitter2.addWidget(self.toolbar)
splitter2.addWidget(self.canvas)
splitter0.addWidget(splitter2)
layout.addWidget(splitter0)
self.setLayout(layout)
self.p = Plot(self.figure, self.data)