Re: [Matplotlib-users] re move / delete arrow / annotate, how to?
Ryan May-3 wrote: You can accomplish it by: ax.texts.remove(arrow) I'd still like to know why this exception gets raised: NotImplementedError Traceback (most recent call last) /home/rmay/ipython console in module() /home/rmay/.local/lib/python2.6/site-packages/matplotlib/artist.pyc in remove(self) 123 self._remove_method(self) 124 else: -- 125 raise NotImplementedError('cannot remove artist') 126 # TODO: the fix for the collections relim problem is to move the 127 # limits calculation into the artist itself, including the property NotImplementedError: cannot remove artist JJ, thoughts? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users Ryan, I implemented this code fine and NEVER got any raised exceptions... Maybe you did something else wrong? - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/remove---delete-arrow---annotate%2C-how-to--tp28451836p28460643.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] re move / delete arrow / annotate, how to?
Hi, I'm trying to remove or delete an annotate arrow but I'm unsuccessful. Can some please help? Thanks. I tried the [artist].remove() but that will not work with arrows or annotate objects... Here is some example code, please add in the code I need if you can: import numpy as np import matplotlib.pyplot as plt t = np.arange(0, np.pi*2, 0.01) x = np.sin(2*np.pi*t) fig = plt.figure() myplot = ax.plot(t, x, 'b') arrow = ax. annotate('my arrow', xy=(3, -0.5), xycoords='data', horizontalalignment='center', verticalalignment='center', color='red', alpha=0.5, xytext=(0, -2), textcoords='offset points', arrowprops=dict(facecolor='red', frac=0.4, shrink = 0.05, alpha=0.5, width=2, headwidth=5), ) #Code to remove arrow... # arrow.remove() #this does not work... plt.show() - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/remove---delete-arrow---annotate%2C-how-to--tp28451836p28451836.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting color of both major and minor gridlines?
Peter Buschman-2 wrote: I ended up finding a solution to this by using a FixedLocator and manually setting each of the tick positions for both major and minor grids without overlap. I'm not sure if this is the recommended way to do this, but hey, it worked ;-) for tick in range(seconds+1)[1:]: if tick % major_multiple == 0: xmajorticks.append(tick) elif tick % minor_multiple == 0: xminorticks.append(tick) ax.xaxis.set_major_locator(FixedLocator(xmajorticks)) ax.xaxis.set_minor_locator(FixedLocator(xminorticks)) Hi there, I know this is an old post, but I'm also trying to do something similar, but using different linestyles for the major and minor grids. Has anyone figured out code that's more efficient than this? It seems that this can slow down my application's data load time. Also, since I'm using the zoom widget, I'm not certain if this will work if the tick markers change If I change my x limits... Any thoughts? - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/Setting-color-of-both-major-and-minor-gridlines--tp9475256p28367421.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] navigationtoolbar: 1. force location; 2. add select button(s) only
Hi, I'm trying to add some navigation tools to my mpl embedded in a wx app. I noticed the default navigation tools here: http://matplotlib.sourceforge.net/users/navigation_toolbar.html?highlight=matplotlib%20widgets http://matplotlib.sourceforge.net/users/navigation_toolbar.html?highlight=matplotlib%20widgets and am able to implement them using this example: http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html . However, I don't want to add the toolbar to the bottom of my canvas or to any part of my canvas. I want to add the toolbar, or actually more specifically, add the pan, zoom, and save buttons to a different panel and sizer. So far I tried adding the navigation toolbar to a different sizer, which is on a different panel, but toolbar always shows up on the canvas. Can someone suggest some methods on how to: 1. force and add the navigation toolbar to a different sizer or panel? 2. Add select buttons from the navigation toolbar to a different sizer or panel than where the canvas is located? Here is my example code: #Boa:Frame:Frame1 import wx import numpy as np import matplotlib as mpl mpl.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure def create(parent): return Frame1(parent) [wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1PANEL2, ] = [wx.NewId() for _init_ctrls in range(3)] class Frame1(wx.Frame): def _init_coll_bshPanels_Items(self, parent): # generated method, don't edit parent.AddWindow(self.panel1, 4, border=0, flag=wx.EXPAND) parent.AddWindow(self.panel2, 1, border=0, flag=wx.EXPAND) def _init_sizers(self): # generated method, don't edit self.bshPanels = wx.BoxSizer(orient=wx.HORIZONTAL) self.bsvPanel1 = wx.BoxSizer(orient=wx.VERTICAL) self.bsvPanel2 = wx.BoxSizer(orient=wx.VERTICAL) self._init_coll_bshPanels_Items(self.bshPanels) self.SetSizer(self.bshPanels) self.panel1.SetSizer(self.bsvPanel1) self.panel2.SetSizer(self.bsvPanel2) def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(-870, 286), size=wx.Size(718, 547), style=wx.DEFAULT_FRAME_STYLE, title='Frame1') self.SetClientSize(wx.Size(710, 520)) self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0), size=wx.Size(568, 520), style=wx.RAISED_BORDER | wx.TAB_TRAVERSAL) self.panel2 = wx.Panel(id=wxID_FRAME1PANEL2, name='panel2', parent=self, pos=wx.Point(568, 0), size=wx.Size(142, 520), style=wx.TAB_TRAVERSAL) self._init_sizers() def __init__(self, parent): self._init_ctrls(parent) self.InitCanvas() self.AddToolBar() self.AddToolBarBtns() self.t = np.arange(0, np.pi*2, 0.01) self.x = np.sin(2*np.pi*self.t) self.myplot = self.ax.plot(self.t, self.x, 'b') self.canvas.draw() def InitCanvas(self): self.fig = Figure(None) self.canvas = FigureCanvasWxAgg(self.panel1, -1, self.fig) self.bsvPanel1.Add(self.canvas, -1, wx.EXPAND) ##self.panel1.Fit() self.ax = self.fig.add_subplot(111) self.ax.grid('On') return True def AddToolBar(self): self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.Realize() tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() self.toolbar.SetSize(wx.Size(fw, th)) #Trying to add to different sizer than to whom the canvas belongs self.bsvPanel2.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) #but this doesn't work. The toolbar is still on the canvas, #but disapears as soon as I resize or do a redraw. #Need correct code here, please. self.toolbar.update() return True def AddToolBarBtns(self): '''add specific tool buttons from the navigatio toolbar to panel2''' #need code here, if possible pass if __name__ == '__main__': app = wx.PySimpleApp() frame = create(None) frame.Show() app.MainLoop() - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/navigationtoolbar%3A-1.-force-location--2.-add-select-button%28s%29-only-tp28268828p28268828.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software
Re: [Matplotlib-users] Forcing full value on axis (Dave Simpson)
I just tried this method and it does work if you are using integers or whole numbers. However, I am working with time on my x axis. So when I zoom too close, floating point numbers are required... Is there any way to just turn off the exponent number in the right corner and force the x tick labels to be integers or floating point depending on how close one is zoomed? David Simpson-3 wrote: I also had some trouble with exponents in an axis, getting 0.0 to 3.0 on the axis, with +1.998e3. I wanted the years 1998 to 2001 instead. I solved this using the following code (with the solution bits commented out): #!/usr/bin/env python from pylab import * # from matplotlib.ticker import FormatStrFormatter x = array([ 1998, 1999, 2000, 2001 ]) y = array([ 2.3, 4.5, 2.6, 7.2 ]) # ax=subplot(111) plot(x,y) ## Needed to get 2001, not 1+2e3: # majorFormatter=FormatStrFormatter('%d') # ax.xaxis.set_major_formatter(majorFormatter) # show() Dave - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/Re%3A-Forcing-full-value-on-axis-%28Dave-Simpson%29-tp10175415p28260517.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axvspan, multiple calls, how to change prop of 1 object instance
I figured it out on my own! Why I couldn't figure it out before... I don't know... Here is the code: myhighlights[1].set_facecolor('y') myhighlights[1].set_xy([[ 3.5 , 0. ],\ [ 3.5 , 1. ], [ 3.75, 1. ], [ 3.75, 0. ], [ 3.5 , 0. ]]) KrishnaPribadi wrote: Hi, I added several axvspan highlights on my plot. I'd like to change the properties of only one of those highlights such as the facecolor, xmin, and xmax. I've included some code below. Lets say I'd like to change the properties on the 2nd vertical highlight (axvspan). Can someone please suggest some code on accessing and changing properties on that specific object? do I access it from the object myhighlights or do I access is from the object ax? Note: This is just some simple code I came up with. My real application is in a wx app GUI so I will be using the draw() function. Here is my code: import numpy as np import matplotlib.pyplot as plt t = np.arange(0, np.pi*2, 0.01) x = np.sin(2*np.pi*t) fig = plt.figure() ax = fig.add_subplot(111) ax.grid('On') myplot = ax.plot(t, x, 'b') myhighlights = [] myhighlights.append(ax.axvspan(1,2, facecolor='g', alpha=0.2)) myhighlights.append(ax.axvspan(3,4, facecolor='g', alpha=0.2)) #later let's change the facecolor, xmin, and xmax myhighlights.append(ax.axvspan(5,6, facecolor='g', alpha=0.2)) #need code to change properties of the 2nd axvspan #change facecolor to yellow #change xmin to 3.5 and xmax to 4.5 plt.show() - Krishna Adrianto Pribadi Test Engineer Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands -- View this message in context: http://old.nabble.com/axvspan%2C-multiple-calls%2C-how-to-change-prop-of-1-object-instance-tp28219155p28219166.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 2 lines, 2 diff colors, when converged, gets 3rd color...
Here my screen shot. Notice the red and green line merging then turning brown... -- View this message in context: http://old.nabble.com/2-lines%2C-2-diff-colors%2C-when-converged%2C-gets-3rd-color...-tp28182679p28190837.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] custom color cycle from cmap
Hi, I'm trying to plot a set of lines, 12 to be exact, and the default color cycle only supports 8 or 9 distinct colors. That said, I looked up the color maps and segmented it using 12 constant intervals with the hope of getting 12 distinct colors. The problem I'm running in to is that some of the line colors I get are too close to each other. This is because come shades in the colormap have a broader spectrum than others. Here is my code to set my custom default color cycle: import matplotlib as mpl cmap = mpl.cm.get_cmap(name='spectral') #I gues we can also use hsv or gist_rainbow nColors = 12 #number of colors incr = 0.9 / nColors self.mycolors = [] for i in np.arange(0,0.9,incr): self.mycolors.append(cmap(i)) mpl.axes.set_default_color_cycle(self.mycolors) Can anyone suggest a cleaner method? Or is there perhaps an existing class to provide distinct color lines? Thanks, Krishna -- View this message in context: http://old.nabble.com/custom-color-cycle-from-cmap-tp28177653p28177653.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] custom color cycle from cmap
Thanks Tony. That helps clean up the code. Now that I think about it more, I actaually had 2 questions. The first you answered well. The second question relates to my problem when using this method in that it produces line colors where some colors are too similar. In other words, there isn't enough of a stark differnece in color between the lines. Can someone suggest a different method (or something that may already be built in) of coming up with 12 or more line colors (more than the built in 8) that are stark? (I know I'm nit-picking and can probably just pick out my own colors but it's an interesting excersize). -- View this message in context: http://old.nabble.com/custom-color-cycle-from-cmap-tp28177653p28180731.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] 2 lines, 2 diff colors, when converged, gets 3rd color...
I'm plotting 2 lines with 2 colors. The lines are binary so they are somewhat square. When the lines converge on a same value for a period, their colors combine and turn into a 3rd color Is there a way to force the plotting to not blend the 2 colors together? I just want the 2nd line to lay on top of the 1st line. Any suggestions? -- View this message in context: http://old.nabble.com/2-lines%2C-2-diff-colors%2C-when-converged%2C-gets-3rd-color...-tp28182679p28182679.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] get/set current index of color cycle, how to
I figured it out, found answer on this site: http://old.nabble.com/Automatically-changing-line-colors-td893139.html#a949316 -- View this message in context: http://old.nabble.com/get-set-current-index-of-color-cycle%2C-how-to-tp27864297p27865867.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users