in tensorwatch/mpl/line_plot.py [0:0]
def init_stream_plot(self, stream_vis,
xtitle='', ytitle='', ztitle='', colormap=None, color=None, xrange=None, yrange=None, linewidth=None, **stream_vis_args):
stream_vis.xylabel_refs = [] # annotation references
import matplotlib
import mpl_toolkits.mplot3d as plt3d
# add main subplot
if len(self._stream_vises) <= 1:
stream_vis.ax = self.get_main_axis()
else:
stream_vis.ax = self.get_main_axis().twinx()
stream_vis.cmap = image_utils.get_cmap(name=colormap or 'Dark2')
if color is None:
if not self.is_3d:
color = stream_vis.cmap((len(self._stream_vises)%stream_vis.cmap.N)/stream_vis.cmap.N) # pylint: disable=no-member
# add default line in subplot
stream_vis.linewidth = linewidth or 3
stream_vis.color = color
if not self.is_3d:
stream_vis.line = matplotlib.lines.Line2D([], [],
label=stream_vis.title or ytitle or str(stream_vis.index), color=color)
else:
stream_vis.line = plt3d.art3d.Line3D([], [], [],
label=stream_vis.title or ytitle or str(stream_vis.index), color=color)
if stream_vis.opacity is not None:
stream_vis.line.set_alpha(stream_vis.opacity)
stream_vis.ax.add_line(stream_vis.line)
stream_vis.fill_between_col = None
# if more than 2 y-axis then place additional outside
if len(self._stream_vises) > 1:
pos = 1 + (len(self._stream_vises)-2) * 0.1
stream_vis.ax.spines['right'].set_position(('axes', pos))
self.make_patch_spines_invisible(stream_vis.ax)
stream_vis.ax.spines["right"].set_visible(True)
stream_vis.ax.set_xlabel(xtitle)
stream_vis.ax.xaxis.label.set_style('italic')
stream_vis.ax.set_ylabel(ytitle)
stream_vis.ax.yaxis.label.set_color(color)
stream_vis.ax.yaxis.label.set_style('italic')
if self.is_3d:
stream_vis.ax.set_zlabel(ztitle)
stream_vis.ax.zaxis.label.set_style('italic')
if xrange is not None:
stream_vis.ax.set_xlim(*xrange)
if yrange is not None:
stream_vis.ax.set_ylim(*yrange)