Python matplotlib.lines() Examples
The following are 30 code examples for showing how to use matplotlib.lines(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: Computable Author: ktraunmueller File: backend_gtk.py License: MIT License | 6 votes |
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()
Example 2
Project: Computable Author: ktraunmueller File: backend_gtk3.py License: MIT License | 6 votes |
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()
Example 3
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 6 votes |
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
Example 4
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk.py License: MIT License | 6 votes |
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()
Example 5
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk3.py License: MIT License | 6 votes |
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()
Example 6
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 6 votes |
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
Example 7
Project: COCO-Style-Dataset-Generator-GUI Author: hanskrupakar File: segment.py License: Apache License 2.0 | 6 votes |
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))
Example 8
Project: COCO-Style-Dataset-Generator-GUI Author: hanskrupakar File: segment.py License: Apache License 2.0 | 6 votes |
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 = []
Example 9
Project: PyXRF Author: NSLS-II File: lineplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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} }
Example 10
Project: PyXRF Author: NSLS-II File: lineplot.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example 11
Project: pylustrator Author: rgerum File: change_tracker.py License: GNU General Public License v3.0 | 6 votes |
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
Example 12
Project: neural-network-animation Author: miloharper File: backend_gtk.py License: MIT License | 6 votes |
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()
Example 13
Project: neural-network-animation Author: miloharper File: backend_gtk3.py License: MIT License | 6 votes |
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()
Example 14
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 6 votes |
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
Example 15
Project: neural-network-animation Author: miloharper File: _base.py License: MIT License | 6 votes |
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)
Example 16
Project: neural-network-animation Author: miloharper File: pyplot.py License: MIT License | 6 votes |
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
Example 17
Project: GraphicDesignPatternByPython Author: Relph1119 File: _base.py License: MIT License | 6 votes |
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
Example 18
Project: GraphicDesignPatternByPython Author: Relph1119 File: _base.py License: MIT License | 6 votes |
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
Example 19
Project: GraphicDesignPatternByPython Author: Relph1119 File: pyplot.py License: MIT License | 6 votes |
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.
Example 20
Project: python3_ios Author: holzschu File: _base.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example 21
Project: psst Author: power-system-simulation-toolbox File: plot.py License: MIT License | 5 votes |
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
Example 22
Project: Computable Author: ktraunmueller File: backend_gtk.py License: MIT License | 5 votes |
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
Example 23
Project: Computable Author: ktraunmueller File: backend_gtk.py License: MIT License | 5 votes |
def get_active_line(self): 'get the active line' ind = self.cbox_lineprops.get_active() line = self.lines[ind] return line
Example 24
Project: Computable Author: ktraunmueller File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 25
Project: Computable Author: ktraunmueller File: pyplot.py License: MIT License | 5 votes |
def figlegend(handles, labels, loc, **kwargs): """ Place a legend in the figure. *labels* a sequence of strings *handles* a sequence of :class:`~matplotlib.lines.Line2D` or :class:`~matplotlib.patches.Patch` instances *loc* can be a string or an integer specifying the legend location A :class:`matplotlib.legend.Legend` instance is returned. Example:: figlegend( (line1, line2, line3), ('label1', 'label2', 'label3'), 'upper right' ) .. seealso:: :func:`~matplotlib.pyplot.legend` """ l = gcf().legend(handles, labels, loc, **kwargs) draw_if_interactive() return l ## Figure and Axes hybrid ##
Example 26
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk.py License: MIT License | 5 votes |
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
Example 27
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk.py License: MIT License | 5 votes |
def get_active_line(self): 'get the active line' ind = self.cbox_lineprops.get_active() line = self.lines[ind] return line
Example 28
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 29
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: pyplot.py License: MIT License | 5 votes |
def figlegend(handles, labels, loc, **kwargs): """ Place a legend in the figure. *labels* a sequence of strings *handles* a sequence of :class:`~matplotlib.lines.Line2D` or :class:`~matplotlib.patches.Patch` instances *loc* can be a string or an integer specifying the legend location A :class:`matplotlib.legend.Legend` instance is returned. Example:: figlegend( (line1, line2, line3), ('label1', 'label2', 'label3'), 'upper right' ) .. seealso:: :func:`~matplotlib.pyplot.legend` """ l = gcf().legend(handles, labels, loc, **kwargs) draw_if_interactive() return l ## Figure and Axes hybrid ##
Example 30
Project: COCO-Style-Dataset-Generator-GUI Author: hanskrupakar File: segment.py License: Apache License 2.0 | 5 votes |
def reset_all(self): self.polys = [] self.text = '' self.points, self.prev, self.submit_p, self.lines, self.circles = [], None, None, [], []