本文整理汇总了Python中matplotlib.collections.LineCollection.to_rgba方法的典型用法代码示例。如果您正苦于以下问题:Python LineCollection.to_rgba方法的具体用法?Python LineCollection.to_rgba怎么用?Python LineCollection.to_rgba使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.LineCollection
的用法示例。
在下文中一共展示了LineCollection.to_rgba方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotcf
# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import to_rgba [as 别名]
def plotcf(grid, phase, modulus, darken=None, axes=None, linestylep="solid", linewidthp=1, color="k", **kwargs):
r"""Plot the modulus of a complex valued function
:math:`f:\mathbb{R} \rightarrow \mathbb{C}`
together with its phase in a color coded fashion.
:param grid: The grid nodes of the real domain R
:param phase: The phase of the complex domain result f(grid)
:param modulus: The modulus of the complex domain result f(grid)
:param darken: Whether to take into account the modulus of the data to darken colors.
:param axes: The axes instance used for plotting.
:param linestylep: The line style of the phase curve.
:param linewidthp: The line width of the phase curve.
:param color: The color of the phase curve.
"""
# Color mapping
rgb_colors = color_map(modulus, phase=phase, modulus=modulus, darken=darken)
# Put all the vertical line into a collection
segments = [array([[node, 0], [node, value]]) for node, value in zip(grid, modulus)]
line_segments = LineCollection(segments)
# Set some properties of the lines
rgb_colors = line_segments.to_rgba(rgb_colors)
line_segments.set_color(rgb_colors[0])
line_segments.set_linestyle(linestylep)
line_segments.set_linewidth(linewidthp)
# Plot to the given axis instance or retrieve the current one
if axes is None:
axes = gca()
# Plot the phase
axes.add_collection(line_segments)
# Plot the modulus
axes.plot(grid, modulus, color=color, **kwargs)
示例2: stemcf
# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import to_rgba [as 别名]
def stemcf(grid, phase, modulus, darken=False, axes=None, linestylep="solid", linewidthp=2, color=None, markerp="o", **kwargs):
r"""
Stemplot the modulus of a complex valued function :math:`f:I \rightarrow C` together with its phase in a color coded fashion.
:param grid: The grid nodes of the real domain R
:param phase: The phase of the complex domain result f(grid)
:param modulus: The modulus of the complex domain result f(grid)
:param darken: Whether to take into account the modulus of the data to darken colors.
:param axes: The axes instance used for plotting.
:param linestylep: The line style of the phase curve.
:param linewidthp: The line width of the phase curve.
:param color: The color of the stemmed markers.
:param markerp: The shape of the stemmed markers.
.. note:: Additional keyword arguments are passe to the plot function.
"""
# Color mapping
rgb_colors = color_map(grid, phase=phase, modulus=modulus, darken=darken)
# Put all the vertical line into a collection
segments = [ array([[node,0], [node,value]]) for node, value in zip(grid, modulus) ]
line_segments = LineCollection(segments)
# Set some properties of the lines
rgb_colors = line_segments.to_rgba(rgb_colors)
line_segments.set_color(rgb_colors[0])
line_segments.set_linestyle(linestylep)
line_segments.set_linewidth(linewidthp)
# Plot to the given axis instance or retrieve the current one
if axes is None:
axes = gca()
# Plot the phase
axes.add_collection(line_segments)
# Plot the modulus
if color is None:
# Scatter has a problem with complex data type, make sure values are purely real
axes.scatter(grid, real(modulus), c=rgb_colors[0], **kwargs)
else:
axes.plot(grid, modulus, linestyle="", marker=markerp, color=color, **kwargs)
# Plot the ground line
axes.plot(grid, zeros(grid.shape), linestyle=linestylep, color="k", **kwargs)
示例3: SunPlotPy
# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import to_rgba [as 别名]
#.........这里部分代码省略.........
self.vbox.Add(self.hbox0, 0, flag = wx.ALIGN_LEFT | wx.TOP)
self.panel.SetSizer(self.vbox)
self.vbox.Fit(self)
##########
# Event functions
##########
def create_figure(self):
"""
Creates the figure
"""
# Find the colorbar limits if unspecified
if self.autoclim:
self.clim = [self.data.min(),self.data.max()]
self.climlow.SetValue('%3.1f'%self.clim[0])
self.climhigh.SetValue('%3.1f'%self.clim[1])
if self.__dict__.has_key('collection'):
#self.collection.remove()
self.axes.collections.remove(self.collection)
else:
# First call - set the axes limits
self.axes.set_aspect('equal')
self.axes.set_xlim(self.xlims)
self.axes.set_ylim(self.ylims)
if self.collectiontype=='cells':
self.collection = PolyCollection(self.xy,cmap=self.cmap)
self.collection.set_array(np.array(self.data[:]))
if not self.showedges:
self.collection.set_edgecolors(self.collection.to_rgba(np.array((self.data[:]))))
elif self.collectiontype=='edges':
xylines = [self.xp[self.edges],self.yp[self.edges]]
linesc = [zip(xylines[0][ii,:],xylines[1][ii,:]) for ii in range(self.Ne)]
self.collection = LineCollection(linesc,array=np.array(self.data[:]),cmap=self.cmap)
self.collection.set_clim(vmin=self.clim[0],vmax=self.clim[1])
self.axes.add_collection(self.collection)
self.title=self.axes.set_title(self.genTitle(),color=self.textcolor)
self.axes.set_xlabel('Easting [m]')
self.axes.set_ylabel('Northing [m]')
# create a colorbar
if not self.__dict__.has_key('cbar'):
self.cbar = self.fig.colorbar(self.collection)
#SetAxColor(self.cbar.ax.axes,self.textcolor,self.bgcolor)
else:
#pass
print 'Updating colorbar...'
#self.cbar.check_update(self.collection)
self.cbar.on_mappable_changed(self.collection)
self.canvas.draw()
def update_figure(self):
if self.autoclim:
self.clim = [self.data.min(),self.data.max()]
self.climlow.SetValue('%3.1f'%self.clim[0])
self.climhigh.SetValue('%3.1f'%self.clim[1])
else:
self.clim = [float(self.climlow.GetValue()),\