本文整理汇总了Python中matplotlib.lines方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.lines方法的具体用法?Python matplotlib.lines怎么用?Python matplotlib.lines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib
的用法示例。
在下文中一共展示了matplotlib.lines方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def show(self):
'populate the combo box'
self._updateson = False
# flush the old
cbox = self.cbox_lineprops
for i in range(self._lastcnt-1,-1,-1):
cbox.remove_text(i)
# add the new
for line in self.lines:
cbox.append_text(line.get_label())
cbox.set_active(0)
self._updateson = True
self._lastcnt = len(self.lines)
self.dlg.show()
示例2: streamplot
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
transform=None, hold=None):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
if hold is not None:
ax.hold(hold)
try:
ret = ax.streamplot(x, y, u, v, density=density, linewidth=linewidth,
color=color, cmap=cmap, norm=norm,
arrowsize=arrowsize, arrowstyle=arrowstyle,
minlength=minlength, transform=transform)
draw_if_interactive()
finally:
ax.hold(washold)
sci(ret.lines)
return ret
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
示例3: reset
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def reset(self, event):
if not self.click_id:
self.click_id = fig.canvas.mpl_connect('button_press_event', self.onclick)
#print (len(self.lines))
#print (len(self.circles))
if len(self.points)>5:
for line in self.lines:
line.pop(0).remove()
for circle in self.circles:
circle.remove()
self.lines, self.circles = [], []
self.p.remove()
self.prev = self.p = None
self.points = []
#print (len(self.lines))
#print (len(self.circles))
示例4: submit
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def submit(self, event):
if not self.right_click:
print ('Right click before submit is a must!!')
else:
self.text+=self.radio.value_selected+'\n'+'%.2f'%self.find_poly_area()+'\n'+self.print_points()+'\n\n'
self.right_click = False
#print (self.points)
self.lines, self.circles = [], []
self.click_id = fig.canvas.mpl_connect('button_press_event', self.onclick)
self.polys.append(Polygon(self.points_to_polygon(), closed=True, color=np.random.rand(3), alpha=0.4, fill=True))
if self.submit_p:
self.submit_p.remove()
self.submit_p = PatchCollection(self.polys, cmap=matplotlib.cm.jet, alpha=0.4)
self.ax.add_collection(self.submit_p)
self.points = []
示例5: _color_config
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def _color_config(self):
self.plot_style = {
'experiment': {'color': 'blue', 'linestyle': '',
'marker': '.', 'label': self.exp_data_label},
'background': {'color': 'indigo', 'marker': '+',
'markersize': 1, 'label': 'background'},
'emission_line': {'color': 'black', 'linewidth': 2},
'roi_line': {'color': 'red', 'linewidth': 2},
'k_line': {'color': 'green', 'label': 'k lines'},
'l_line': {'color': 'magenta', 'label': 'l lines'},
'm_line': {'color': 'brown', 'label': 'm lines'},
'compton': {'color': 'darkcyan', 'linewidth': 1.5, 'label': 'compton'},
'elastic': {'color': 'purple', 'label': 'elastic'},
'escape': {'color': 'darkblue', 'label': 'escape'},
'pileup': {'color': 'darkgoldenrod', 'label': 'pileup'},
'userpeak': {'color': 'orange', 'label': 'userpeak'},
# 'auto_fit': {'color': 'black', 'label': 'auto fitted', 'linewidth': 2.5},
'fit': {'color': 'red', 'label': 'fit', 'linewidth': 2.5},
'residual': {'color': 'black', 'label': 'residual', 'linewidth': 2.0}
}
示例6: plot_emission_line
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def plot_emission_line(self):
"""
Plot emission line and escape peaks associated with given lines.
The value of self.max_v is needed in this function in order to plot
the relative height of each emission line.
"""
while(len(self.eline_obj)):
self.eline_obj.pop().remove()
escape_e = self.escape_e
if len(self.elist):
for i in range(len(self.elist)):
eline, = self._ax.plot([self.elist[i][0], self.elist[i][0]],
[0, self.elist[i][1]*self.max_v],
color=self.plot_style['emission_line']['color'],
linewidth=self.plot_style['emission_line']['linewidth'])
self.eline_obj.append(eline)
if self.plot_escape_line and self.elist[i][0] > escape_e:
eline, = self._ax.plot([self.elist[i][0]-escape_e,
self.elist[i][0]-escape_e],
[0, self.elist[i][1]*self.max_v],
color=self.plot_style['escape']['color'],
linewidth=self.plot_style['emission_line']['linewidth'])
self.eline_obj.append(eline)
示例7: save
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def save(self):
""" save the changes to the .py file """
header = [getReference(self.figure) + ".ax_dict = {ax.get_label(): ax for ax in " + getReference(
self.figure) + ".axes}", "import matplotlib as mpl"]
# block = getTextFromFile(header[0], self.stack_position)
output = ["#% start: automatic generated code from pylustrator"]
# add the lines from the header
for line in header:
output.append(line)
# add all lines from the changes
for line in self.sorted_changes():
output.append(line)
if line.startswith("fig.add_axes"):
output.append(header[1])
output.append("#% end: automatic generated code from pylustrator")
# print("\n".join(output))
block_id = getReference(self.figure)
block = getTextFromFile(block_id, stack_position)
if not block:
block_id = getReference(self.figure, allow_using_variable_names=False)
block = getTextFromFile(block_id, stack_position)
insertTextToFile(output, stack_position, block_id)
self.saved = True
示例8: add_line
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def add_line(self, line):
"""
Add a :class:`~matplotlib.lines.Line2D` to the list of plot
lines
Returns the line.
"""
self._set_artist_props(line)
if line.get_clip_path() is None:
line.set_clip_path(self.patch)
self._update_line_limits(line)
if not line.get_label():
line.set_label('_line%d' % len(self.lines))
self.lines.append(line)
line._remove_method = lambda h: self.lines.remove(h)
return line
示例9: relim
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def relim(self, visible_only=False):
"""
Recompute the data limits based on current artists. If you want to
exclude invisible artists from the calculation, set
``visible_only=True``
At present, :class:`~matplotlib.collections.Collection`
instances are not supported.
"""
# Collections are deliberately not supported (yet); see
# the TODO note in artists.py.
self.dataLim.ignore(True)
self.dataLim.set_points(mtransforms.Bbox.null().get_points())
self.ignore_existing_data_limits = True
for line in self.lines:
if not visible_only or line.get_visible():
self._update_line_limits(line)
for p in self.patches:
if not visible_only or p.get_visible():
self._update_patch_limits(p)
示例10: streamplot
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
transform=None, zorder=1, hold=None):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
if hold is not None:
ax.hold(hold)
try:
ret = ax.streamplot(x, y, u, v, density=density, linewidth=linewidth,
color=color, cmap=cmap, norm=norm,
arrowsize=arrowsize, arrowstyle=arrowstyle,
minlength=minlength, transform=transform,
zorder=zorder)
draw_if_interactive()
finally:
ax.hold(washold)
sci(ret.lines)
return ret
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
示例11: add_line
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def add_line(self, line):
"""
Add a :class:`~matplotlib.lines.Line2D` to the list of plot
lines
Returns the line.
"""
self._set_artist_props(line)
if line.get_clip_path() is None:
line.set_clip_path(self.patch)
self._update_line_limits(line)
if not line.get_label():
line.set_label('_line%d' % len(self.lines))
self.lines.append(line)
line._remove_method = self.lines.remove
self.stale = True
return line
示例12: get_children
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def get_children(self):
"""return a list of child artists"""
children = []
children.extend(self.collections)
children.extend(self.patches)
children.extend(self.lines)
children.extend(self.texts)
children.extend(self.artists)
children.extend(self.spines.values())
children.append(self.xaxis)
children.append(self.yaxis)
children.append(self.title)
children.append(self._left_title)
children.append(self._right_title)
children.extend(self.tables)
children.extend(self.images)
children.extend(self.child_axes)
if self.legend_ is not None:
children.append(self.legend_)
children.append(self.patch)
return children
示例13: streamplot
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def streamplot(
x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
transform=None, zorder=None, start_points=None, maxlength=4.0,
integration_direction='both', *, data=None):
__ret = gca().streamplot(
x=x, y=y, u=u, v=v, density=density, linewidth=linewidth,
color=color, cmap=cmap, norm=norm, arrowsize=arrowsize,
arrowstyle=arrowstyle, minlength=minlength,
transform=transform, zorder=zorder, start_points=start_points,
maxlength=maxlength,
integration_direction=integration_direction, data=data)
sci(__ret.lines)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
示例14: plot_costs
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def plot_costs(case, number_of_segments=1, ax=None, legend=True):
if ax is None:
fig, axs = plt.subplots(1, 1, figsize=(16, 10))
ax = axs
color_scale = make_interpolater(0, len(case.gen_name), 0, 1)
color = {g: plt.cm.jet(color_scale(i)) for i, g in enumerate(case.gen_name)}
for s in calculate_segments(case, number_of_segments=number_of_segments):
pmin, pmax = s['segment']
x = np.linspace(pmin, pmax)
y = x * s['slope']
ax.plot(x, y, color=color[s['name']])
ax = ax.twinx()
for s in calculate_segments(case, number_of_segments=number_of_segments):
pmin, pmax = s['segment']
x = np.linspace(pmin, pmax)
y = [s['slope'] for _ in x]
ax.plot(x, y, color=color[s['name']])
ax.set_ylim(0, 1.2*y[-1])
if legend:
lines = list()
for g in case.gen_name:
lines.append(mlines.Line2D([], [], color=color[g], label=g))
ax.legend(handles=lines, loc='upper left')
return ax
示例15: __init__
# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import lines [as 别名]
def __init__(self, lines):
import gtk.glade
datadir = matplotlib.get_data_path()
gladefile = os.path.join(datadir, 'lineprops.glade')
if not os.path.exists(gladefile):
raise IOError('Could not find gladefile lineprops.glade in %s'%datadir)
self._inited = False
self._updateson = True # suppress updates when setting widgets manually
self.wtree = gtk.glade.XML(gladefile, 'dialog_lineprops')
self.wtree.signal_autoconnect(dict([(s, getattr(self, s)) for s in self.signals]))
self.dlg = self.wtree.get_widget('dialog_lineprops')
self.lines = lines
cbox = self.wtree.get_widget('combobox_lineprops')
cbox.set_active(0)
self.cbox_lineprops = cbox
cbox = self.wtree.get_widget('combobox_linestyles')
for ls in self.linestyles:
cbox.append_text(ls)
cbox.set_active(0)
self.cbox_linestyles = cbox
cbox = self.wtree.get_widget('combobox_markers')
for m in self.markers:
cbox.append_text(m)
cbox.set_active(0)
self.cbox_markers = cbox
self._lastcnt = 0
self._inited = True