From jni.soma at gmail.com Mon Nov 7 19:02:08 2016 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 8 Nov 2016 11:02:08 +1100 Subject: [Matplotlib-users] prop_cycle has no effect on scatter Message-ID: Hi, I'm trying to define a matplotlib style. I've set the color cycler correctly for `plot` calls, but all `scatter` calls result in blue dots. Is there a way to create a cycler for `scatter` calls? What's the recommended usage here? Juan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Nov 7 20:00:20 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 08 Nov 2016 01:00:20 +0000 Subject: [Matplotlib-users] prop_cycle has no effect on scatter In-Reply-To: References: Message-ID: In <=1.5 scatter does not respect the color cycle, doing so will be one of the style changes in 2.0 ( http://matplotlib.org/devdocs/users/dflt_style_changes.html#scatter) Tom On Mon, Nov 7, 2016 at 7:02 PM Juan Nunez-Iglesias wrote: > Hi, > > I'm trying to define a matplotlib style. I've set the color cycler > correctly for `plot` calls, but all `scatter` calls result in blue dots. Is > there a way to create a cycler for `scatter` calls? What's the recommended > usage here? > > Juan. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Nov 7 20:38:27 2016 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 8 Nov 2016 12:38:27 +1100 Subject: [Matplotlib-users] prop_cycle has no effect on scatter In-Reply-To: References: Message-ID: Ah! Thanks. That might be something worth waiting for... (For Elegant SciPy.) What's the timeline on 2.0? =) On Tue, Nov 8, 2016 at 12:00 PM, Thomas Caswell wrote: > In <=1.5 scatter does not respect the color cycle, doing so will be one of > the style changes in 2.0 (http://matplotlib.org/devdocs/users/dflt_style_ > changes.html#scatter) > > Tom > > On Mon, Nov 7, 2016 at 7:02 PM Juan Nunez-Iglesias > wrote: > >> Hi, >> >> I'm trying to define a matplotlib style. I've set the color cycler >> correctly for `plot` calls, but all `scatter` calls result in blue dots. Is >> there a way to create a cycler for `scatter` calls? What's the recommended >> usage here? >> >> Juan. >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Nov 7 20:40:09 2016 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 8 Nov 2016 12:40:09 +1100 Subject: [Matplotlib-users] Style axes for imshow only Message-ID: Is there a way to set different axis style for imshow plots using a style file? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Nov 7 21:19:32 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 08 Nov 2016 02:19:32 +0000 Subject: [Matplotlib-users] Style axes for imshow only In-Reply-To: References: Message-ID: No, `Axes` do not know a head of time what type of artists they will host (which is both a feature and a bug depending on who you ask). `imshow` _does_ change some `Axes` properties (in addition to adding the requisite artists) such as setting the aspect ratio. In principle we could have an `image.axis.top` and friends rcParams, but then we maybe should have them for _all_ of the 'basic' plotting methods. Not only would this lead to a great explosion of rcParams, we would also have to deal with conflicts / rules about how to settle conflicts (which sounds like a big mess to me). I suggest writting a helper function like: def my_imshow_that_changes_axis_visibilty(ax, data, **kwargs): # set axis visibility as you desire return ax.imshow(data, **kwargs) or def set_up_axes_axis_the_way_i_like_for_imshow(ax): # set up the axis the way you want Tom On Mon, Nov 7, 2016 at 8:40 PM Juan Nunez-Iglesias wrote: > Is there a way to set different axis style for imshow plots using a style > file? > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Mon Nov 7 22:30:56 2016 From: wrw at mac.com (William Ray Wing) Date: Mon, 07 Nov 2016 22:30:56 -0500 Subject: [Matplotlib-users] Controlling the number of displayed digits in time axis labels Message-ID: <592504B2-8F9C-4ACB-BEBB-30D78782BB03@mac.com> I need to plot some time series data in which the time axis is specified by numpy/pandas 64-bit date-time values. I?m only interested in hours, minutes, and seconds, and the seconds value is only accurate to hundredths. I?m formatting the time axis as: x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?) which gives me hours, minutes, and seconds, BUT gives me six digits of bogus precision after the seconds decimal point. Is there any way to truncate those six digits to three. I?ve tried several Google searches, but have been unsuccessful in coming up with anything. Thanks, Bill From tcaswell at gmail.com Mon Nov 7 23:47:04 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 08 Nov 2016 04:47:04 +0000 Subject: [Matplotlib-users] Controlling the number of displayed digits in time axis labels In-Reply-To: <592504B2-8F9C-4ACB-BEBB-30D78782BB03@mac.com> References: <592504B2-8F9C-4ACB-BEBB-30D78782BB03@mac.com> Message-ID: The defaults will be improved in 2.0 (see http://matplotlib.org/devdocs/users/dflt_style_changes.html#autodateformatter-format-strings ) Can you provide a more complete example of what you are doing that is not working? Tom On Mon, Nov 7, 2016 at 11:31 PM William Ray Wing wrote: > I need to plot some time series data in which the time axis is specified > by numpy/pandas 64-bit date-time values. I?m only interested in hours, > minutes, and seconds, and the seconds value is only accurate to > hundredths. I?m formatting the time axis as: > > x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?) > > which gives me hours, minutes, and seconds, BUT gives me six digits of > bogus precision after the seconds decimal point. Is there any way to > truncate those six digits to three. I?ve tried several Google searches, > but have been unsuccessful in coming up with anything. > > Thanks, > Bill > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Tue Nov 8 08:15:34 2016 From: wrw at mac.com (William Ray Wing) Date: Tue, 08 Nov 2016 08:15:34 -0500 Subject: [Matplotlib-users] Controlling the number of displayed digits in time axis labels In-Reply-To: References: <592504B2-8F9C-4ACB-BEBB-30D78782BB03@mac.com> Message-ID: Sure (and thanks for helping me with this). The data is read from a csv file, the pieces I?m looking at are extracted and I generate four sub-plots, the first of which axs[0,0] is NOT a time series, but the next three are. The code below includes my imports and the code to generate the second and third sub-plot. The second, third, and last sub-plots all have the same time axis, but the labels are only drawn on the bottom two (1,0 and 1,1). I assume if I explicitly made space under the 0,0 and 0,1 plots, they would grow labels too. Thanks, Bill ???????cut on dotted line???? #! /usr/bin/env python import pandas as pd, matplotlib.pyplot as plt, numpy as np import matplotlib.dates . . . # # Next plot # ax = axs[0,1] x_format = mpdates.DateFormatter('%H:%M:%S') ax.xaxis.set_major_formatter(x_format) fig.autofmt_xdate() ax.plot(wdx,wdyH2Oc_, 'b') ax.axis([dndx[0],dndx[vec_len-1], 12000, 15500]) ax.set_title('H2Oc_ppm') # # Next plot # ax = axs[1,0] ax.plot(wdx,wdyO18_d) ax.set_title('O18_del') ax.axis([dndx[0], dndx[vec_len-1],-55,-25]) > On Nov 7, 2016, at 11:47 PM, Thomas Caswell wrote: > > The defaults will be improved in 2.0 (see http://matplotlib.org/devdocs/users/dflt_style_changes.html#autodateformatter-format-strings ) > > Can you provide a more complete example of what you are doing that is not working? > > Tom > > On Mon, Nov 7, 2016 at 11:31 PM William Ray Wing > wrote: > I need to plot some time series data in which the time axis is specified by numpy/pandas 64-bit date-time values. I?m only interested in hours, minutes, and seconds, and the seconds value is only accurate to hundredths. I?m formatting the time axis as: > > x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?) > > which gives me hours, minutes, and seconds, BUT gives me six digits of bogus precision after the seconds decimal point. Is there any way to truncate those six digits to three. I?ve tried several Google searches, but have been unsuccessful in coming up with anything. > > Thanks, > Bill > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Fri Nov 11 12:48:44 2016 From: ben.v.root at gmail.com (Benjamin Root) Date: Fri, 11 Nov 2016 12:48:44 -0500 Subject: [Matplotlib-users] feedback request - plot_surface()/plot_wireframe() Message-ID: Hello all, I am doing a "style change" for v2.0 with the long reviled rstride/cstride arguments to plot_surface(). No, I am not changing the default to 1. But I am adding two new arguments: "rcount/ccount" to allow users to specify the maximum number of evenly spaced samples to take from the input data. rcount and ccount will be the default sampling method for plot_surface() (unless the 'classic' mode is turned on). As I was putting together this PR, I remembered that plot_wireframe() also takes rstride/cstride, so it makes sense to add the rcount/ccount feature to it as well. However, the question I pose to the users: "should rcount/ccount be the new sampling method in plot_wireframe()?" I would appreciate any and all feedback on this question. PR is https://github.com/matplotlib/matplotlib/pull/7164 Cheers! Ben Root -------------- next part -------------- An HTML attachment was scrubbed... URL: From deh at case.edu Tue Nov 15 12:54:36 2016 From: deh at case.edu (Dale Huffman) Date: Tue, 15 Nov 2016 12:54:36 -0500 Subject: [Matplotlib-users] widgets: RectangleSelector return values Message-ID: <90e059f7-9340-f29a-ea54-5a6308b957f3@case.edu> I was using the RectangleSelector widget from an older version of matplotlib and it returned the eclick and erelease objects, matching the example code in the docstring. The eclick.xdata and eclick.ydata matched the click event and the erelease.xdata and erelease.ydata matched the release event. In the new 1.5.3 version (probably recent older versions also - not sure exactly when it changed) it is only returning the extents of the rectangle, regardless of whether they occurred on the click or release event. For example if you select the rectangle from top/left to bottom/right you get the same values as is you have selected from bottom/left to top/right. Unfortunately, I am using this information to do different things, base on the direction of the rectangle selection. Is this new method intentional, or is it a bug? I've made a crappy patch for the code to work for me, but obviously don't want to do this at each update to matplotlib. Either way it seems to me that either the docstring needs to be updated to show the new extents based version or the code changed to return the actual data from the two events, instead of just the extents of the rectangle. Please educate me if I'm completely off base here. From tcaswell at gmail.com Tue Nov 15 13:17:27 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Tue, 15 Nov 2016 18:17:27 +0000 Subject: [Matplotlib-users] widgets: RectangleSelector return values In-Reply-To: <90e059f7-9340-f29a-ea54-5a6308b957f3@case.edu> References: <90e059f7-9340-f29a-ea54-5a6308b957f3@case.edu> Message-ID: That seems like an intentional change to me, but one we might want to reconsider. I think this change went in via https://github.com/matplotlib/matplotlib/pull/3937 At a minimum, the selector should probably grow an option to preserve the order. Tom On Tue, Nov 15, 2016 at 12:56 PM Dale Huffman wrote: > I was using the RectangleSelector widget from an older version of > matplotlib and it returned the eclick and erelease objects, matching the > example code in the docstring. The eclick.xdata and eclick.ydata > matched the click event and the erelease.xdata and erelease.ydata > matched the release event. > In the new 1.5.3 version (probably recent older versions also - not sure > exactly when it changed) it is only returning the extents of the > rectangle, regardless of whether they occurred on the click or release > event. For example if you select the rectangle from top/left to > bottom/right you get the same values as is you have selected from > bottom/left to top/right. > Unfortunately, I am using this information to do different things, base > on the direction of the rectangle selection. Is this new method > intentional, or is it a bug? I've made a crappy patch for the code to > work for me, but obviously don't want to do this at each update to > matplotlib. Either way it seems to me that either the docstring needs > to be updated to show the new extents based version or the code changed > to return the actual data from the two events, instead of just the > extents of the rectangle. > Please educate me if I'm completely off base here. > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pprodano at gmail.com Sat Nov 19 07:24:12 2016 From: pprodano at gmail.com (Pat Prodanovic) Date: Sat, 19 Nov 2016 07:24:12 -0500 Subject: [Matplotlib-users] Matplotlib with invalid triangulations Message-ID: <0d5ea570-08c5-3c5f-9a42-3cda5ae163b2@gmail.com> Hello, I am using JR Shewchuk's Triangle to create triangulations for use in floodplain modeling. I am using a city's digital terrain model with hundreds of thousands of breaklines that constrain where triangles can form in the triangulations (streets, rivers, etc). Triangle does this very efficiently. Sometimes the input topology I am using has bad inputs which makes Triangle create zero area elements. When I import these triangulations to Matplotlib I get the error that such triangulations are invalid (when using the LinearTriInterpolator() method). I understand the trapezoid map algorithm implemented requires only valid triangulations. So far, so good. The option of cleaning the input topology before using Matplotlib exists, but it is really cumbersome. Rather than topology cleaning, am I am able to somehow throw out the zero area elements from the call to LinearTriInterpolator() method, and still use the triangulation in Matplotlib? My other alternative is to use something other than trapezoidal map algorithm, but this is just not computationally efficient. I've reproduced the following example that illustrates the problem in a small code snippet. Any suggestions? Thanks, Pat Prodanovic # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- import matplotlib.tri as mtri import numpy as np # manually construct an invalid triangulation having a zero area element x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) z = np.zeros(5) triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) # create a Matplotlib Triangulation triang = mtri.Triangulation(x,y,triangles) # to perform the linear interpolation interpolator = mtri.LinearTriInterpolator(triang, z) m_z = interpolator(1.0, 1.0) # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- From ianthomas23 at gmail.com Mon Nov 21 03:47:22 2016 From: ianthomas23 at gmail.com (Ian Thomas) Date: Mon, 21 Nov 2016 08:47:22 +0000 Subject: [Matplotlib-users] Matplotlib with invalid triangulations In-Reply-To: <0d5ea570-08c5-3c5f-9a42-3cda5ae163b2@gmail.com> References: <0d5ea570-08c5-3c5f-9a42-3cda5ae163b2@gmail.com> Message-ID: Hello Pat, The solution is to use the function Triangulation.set_mask() to mask out the zero-area triangles. The masked-out triangles will be ignored in subsequent calls to LinearTriInterpolator, tricontourf, etc. For example: # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- import matplotlib.tri as mtri import numpy as np # manually construct an invalid triangulation having a zero area element x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) z = np.zeros(5) triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) # create a Matplotlib Triangulation triang = mtri.Triangulation(x,y,triangles) # ---------- start of new code ---------- xy = np.dstack((triang.x[triang.triangles], triang.y[triang.triangles])) # shape (ntri,3,2) twice_area = np.cross(xy[:,1,:] - xy[:,0,:], xy[:,2,:] - xy[:,0,:]) # shape (ntri) mask = twice_area < 1e-10 # shape (ntri) if np.any(mask): triang.set_mask(mask) # ---------- end of new code ---------- # to perform the linear interpolation interpolator = mtri.LinearTriInterpolator(triang, z) m_z = interpolator(1.0, 1.0) # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Note that I have used a small positive number to test the triangle areas against rather than zero. This is to avoid problems with rounding errors. You may need to alter this threshold. Ian On 19 November 2016 at 12:24, Pat Prodanovic wrote: > Hello, > > I am using JR Shewchuk's Triangle to create triangulations for use in > floodplain modeling. I am using a city's digital terrain model with > hundreds of thousands of breaklines that constrain where triangles can form > in the triangulations (streets, rivers, etc). Triangle does this very > efficiently. > > Sometimes the input topology I am using has bad inputs which makes > Triangle create zero area elements. When I import these triangulations to > Matplotlib I get the error that such triangulations are invalid (when using > the LinearTriInterpolator() method). I understand the trapezoid map > algorithm implemented requires only valid triangulations. So far, so good. > > The option of cleaning the input topology before using Matplotlib exists, > but it is really cumbersome. Rather than topology cleaning, am I am able to > somehow throw out the zero area elements from the call to > LinearTriInterpolator() method, and still use the triangulation in > Matplotlib? My other alternative is to use something other than trapezoidal > map algorithm, but this is just not computationally efficient. > > I've reproduced the following example that illustrates the problem in a > small code snippet. Any suggestions? > > Thanks, > > Pat Prodanovic > > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > import matplotlib.tri as mtri > import numpy as np > > # manually construct an invalid triangulation having a zero area element > x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) > y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) > z = np.zeros(5) > > triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) > > # create a Matplotlib Triangulation > triang = mtri.Triangulation(x,y,triangles) > > # to perform the linear interpolation > interpolator = mtri.LinearTriInterpolator(triang, z) > m_z = interpolator(1.0, 1.0) > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pprodano at gmail.com Mon Nov 21 06:45:06 2016 From: pprodano at gmail.com (Pat Prodanovic) Date: Mon, 21 Nov 2016 06:45:06 -0500 Subject: [Matplotlib-users] Matplotlib with invalid triangulations In-Reply-To: References: <0d5ea570-08c5-3c5f-9a42-3cda5ae163b2@gmail.com> Message-ID: Hi Ian, Thank you for your reply. The modification you provided correctly finds the zero area element, and masks it from the triangulation. In the example from the previous post, masking the zero area element works. When I try and make a slightly different triangulation (see below), and try to mask the zero area elements, I still get an invalid triangulation. I am using v1.4.2. Do you have a sense as to what could be going on here? Thanks, Pat import matplotlib.tri as mtri import numpy as np # manually construct an invalid triangulation x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) z = np.zeros(5) # slightly modified from what I originally posted triangles = np.array( [[0, 1, 4], [2, 3, 4], [0, 3, 2], [0, 4, 3]]) # create a Matplotlib Triangulation triang = mtri.Triangulation(x,y,triangles) # ---------- start of new code ---------- xy = np.dstack((triang.x[triang.triangles], triang.y[triang.triangles])) #shape (ntri,3,2) twice_area = np.cross(xy[:,1,:] - xy[:,0,:], xy[:,2,:] - xy[:,0,:]) # shape (ntri) mask = twice_area < 1e-10 # shape (ntri) if np.any(mask): triang.set_mask(mask) # ---------- end of new code ---------- # to perform the linear interpolation interpolator = mtri.LinearTriInterpolator(triang, z) m_z = interpolator(1.0, 1.0) On 11/21/2016 03:47 AM, Ian Thomas wrote: > Hello Pat, > > The solution is to use the function Triangulation.set_mask() to mask > out the zero-area triangles. The masked-out triangles will be ignored > in subsequent calls to LinearTriInterpolator, tricontourf, etc. For > example: > > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > import matplotlib.tri as mtri > import numpy as np > > # manually construct an invalid triangulation having a zero area element > x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) > y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) > z = np.zeros(5) > > triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) > > # create a Matplotlib Triangulation > triang = mtri.Triangulation(x,y,triangles) > > # ---------- start of new code ---------- > xy = np.dstack((triang.x[triang.triangles], > triang.y[triang.triangles])) # shape (ntri,3,2) > twice_area = np.cross(xy[:,1,:] - xy[:,0,:], xy[:,2,:] - xy[:,0,:]) # > shape (ntri) > mask = twice_area < 1e-10 # shape (ntri) > > if np.any(mask): > triang.set_mask(mask) > # ---------- end of new code ---------- > > # to perform the linear interpolation > interpolator = mtri.LinearTriInterpolator(triang, z) > m_z = interpolator(1.0, 1.0) > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > > Note that I have used a small positive number to test the triangle > areas against rather than zero. This is to avoid problems with > rounding errors. You may need to alter this threshold. > > Ian > > > On 19 November 2016 at 12:24, Pat Prodanovic > wrote: > > Hello, > > I am using JR Shewchuk's Triangle to create triangulations for use > in floodplain modeling. I am using a city's digital terrain model > with hundreds of thousands of breaklines that constrain where > triangles can form in the triangulations (streets, rivers, etc). > Triangle does this very efficiently. > > Sometimes the input topology I am using has bad inputs which makes > Triangle create zero area elements. When I import these > triangulations to Matplotlib I get the error that such > triangulations are invalid (when using the LinearTriInterpolator() > method). I understand the trapezoid map algorithm implemented > requires only valid triangulations. So far, so good. > > The option of cleaning the input topology before using Matplotlib > exists, but it is really cumbersome. Rather than topology > cleaning, am I am able to somehow throw out the zero area elements > from the call to LinearTriInterpolator() method, and still use the > triangulation in Matplotlib? My other alternative is to use > something other than trapezoidal map algorithm, but this is just > not computationally efficient. > > I've reproduced the following example that illustrates the problem > in a small code snippet. Any suggestions? > > Thanks, > > Pat Prodanovic > > # > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > import matplotlib.tri as mtri > import numpy as np > > # manually construct an invalid triangulation having a zero area > element > x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) > y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) > z = np.zeros(5) > > triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) > > # create a Matplotlib Triangulation > triang = mtri.Triangulation(x,y,triangles) > > # to perform the linear interpolation > interpolator = mtri.LinearTriInterpolator(triang, z) > m_z = interpolator(1.0, 1.0) > # > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ianthomas23 at gmail.com Tue Nov 22 05:04:22 2016 From: ianthomas23 at gmail.com (Ian Thomas) Date: Tue, 22 Nov 2016 10:04:22 +0000 Subject: [Matplotlib-users] Matplotlib with invalid triangulations In-Reply-To: References: <0d5ea570-08c5-3c5f-9a42-3cda5ae163b2@gmail.com> Message-ID: Hi Pat, That's really unlucky! Point 3 at (1,1) lies along one edge of triangle (0, 1, 4). However, due to rounding error caused by finite-precision maths, there is some test when creating LinearTriInterpolator for which point 3 lies just inside triangle (0, 1, 4). Hence the triangulation is invalid. You can prove this by changing the line y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) to y = np.array([1.0, 0.0, 2.0, 1.0+1e-10, 1.0]) instead. Really the only solution if you want to use LinearTriInterpolator is to ensure that you don't have any very thin triangles before going anywhere near matplotlib. This is down to whatever you use to generate your triangulation and/or whatever preprocessing you perform on it. Ian On 21 November 2016 at 11:45, Pat Prodanovic wrote: > Hi Ian, > > Thank you for your reply. > > The modification you provided correctly finds the zero area element, and > masks it from the triangulation. In the example from the previous post, > masking the zero area element works. > > When I try and make a slightly different triangulation (see below), and > try to mask the zero area elements, I still get an invalid triangulation. I > am using v1.4.2. Do you have a sense as to what could be going on here? > > Thanks, > > Pat > > import matplotlib.tri as mtri > import numpy as np > > # manually construct an invalid triangulation > x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) > y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) > z = np.zeros(5) > > # slightly modified from what I originally posted > triangles = np.array( [[0, 1, 4], [2, 3, 4], [0, 3, 2], [0, 4, 3]]) > > # create a Matplotlib Triangulation > triang = mtri.Triangulation(x,y,triangles) > > # ---------- start of new code ---------- > xy = np.dstack((triang.x[triang.triangles], triang.y[triang.triangles])) > #shape (ntri,3,2) > twice_area = np.cross(xy[:,1,:] - xy[:,0,:], xy[:,2,:] - xy[:,0,:]) # > shape (ntri) > mask = twice_area < 1e-10 # shape (ntri) > > if np.any(mask): > triang.set_mask(mask) > # ---------- end of new code ---------- > > # to perform the linear interpolation > interpolator = mtri.LinearTriInterpolator(triang, z) > m_z = interpolator(1.0, 1.0) > On 11/21/2016 03:47 AM, Ian Thomas wrote: > > Hello Pat, > > The solution is to use the function Triangulation.set_mask() to mask out > the zero-area triangles. The masked-out triangles will be ignored in > subsequent calls to LinearTriInterpolator, tricontourf, etc. For example: > > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > import matplotlib.tri as mtri > import numpy as np > > # manually construct an invalid triangulation having a zero area element > x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) > y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) > z = np.zeros(5) > > triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) > > # create a Matplotlib Triangulation > triang = mtri.Triangulation(x,y,triangles) > > # ---------- start of new code ---------- > xy = np.dstack((triang.x[triang.triangles], triang.y[triang.triangles])) > # shape (ntri,3,2) > twice_area = np.cross(xy[:,1,:] - xy[:,0,:], xy[:,2,:] - xy[:,0,:]) # > shape (ntri) > mask = twice_area < 1e-10 # shape (ntri) > > if np.any(mask): > triang.set_mask(mask) > # ---------- end of new code ---------- > > # to perform the linear interpolation > interpolator = mtri.LinearTriInterpolator(triang, z) > m_z = interpolator(1.0, 1.0) > # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- > > Note that I have used a small positive number to test the triangle areas > against rather than zero. This is to avoid problems with rounding errors. > You may need to alter this threshold. > > Ian > > > On 19 November 2016 at 12:24, Pat Prodanovic wrote: > >> Hello, >> >> I am using JR Shewchuk's Triangle to create triangulations for use in >> floodplain modeling. I am using a city's digital terrain model with >> hundreds of thousands of breaklines that constrain where triangles can form >> in the triangulations (streets, rivers, etc). Triangle does this very >> efficiently. >> >> Sometimes the input topology I am using has bad inputs which makes >> Triangle create zero area elements. When I import these triangulations to >> Matplotlib I get the error that such triangulations are invalid (when using >> the LinearTriInterpolator() method). I understand the trapezoid map >> algorithm implemented requires only valid triangulations. So far, so good. >> >> The option of cleaning the input topology before using Matplotlib exists, >> but it is really cumbersome. Rather than topology cleaning, am I am able to >> somehow throw out the zero area elements from the call to >> LinearTriInterpolator() method, and still use the triangulation in >> Matplotlib? My other alternative is to use something other than trapezoidal >> map algorithm, but this is just not computationally efficient. >> >> I've reproduced the following example that illustrates the problem in a >> small code snippet. Any suggestions? >> >> Thanks, >> >> Pat Prodanovic >> >> # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- >> import matplotlib.tri as mtri >> import numpy as np >> >> # manually construct an invalid triangulation having a zero area element >> x = np.array([0.0, 1.0, 1.0, 1.0, 2.0]) >> y = np.array([1.0, 0.0, 2.0, 1.0, 1.0]) >> z = np.zeros(5) >> >> triangles = np.array( [[0, 1, 2], [1, 3, 2], [1, 4, 2], [0, 4, 1]]) >> >> # create a Matplotlib Triangulation >> triang = mtri.Triangulation(x,y,triangles) >> >> # to perform the linear interpolation >> interpolator = mtri.LinearTriInterpolator(triang, z) >> m_z = interpolator(1.0, 1.0) >> # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tanim.islam at gmail.com Thu Nov 24 15:34:47 2016 From: tanim.islam at gmail.com (Tanim Islam) Date: Thu, 24 Nov 2016 12:34:47 -0800 Subject: [Matplotlib-users] how to create a double-sided arrow of arbitrary width with matplotlib's annotate(...) method? Message-ID: Hello, Does anyone have a one-method annotate(...) example to create a double-sided arrow, of arbitrary width? I was able to do so but only by hacking together two one-sided annotate(...) methods. Tanim Islam -------------- next part -------------- An HTML attachment was scrubbed... URL: From Nicolas.Rougier at inria.fr Sat Nov 26 09:21:16 2016 From: Nicolas.Rougier at inria.fr (Nicolas P. Rougier) Date: Sat, 26 Nov 2016 15:21:16 +0100 Subject: [Matplotlib-users] How to draw a collection of oriented triangles ? Message-ID: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> I would like to draw several triangles (same size, same color) with different individual orientations. Scatter plot does not allow to specify individual orientations and I've a hard time with PatchCollection. What would be the easiest way ? Is there an example somewhere around by any chance ? Nicolas From mobiusklein at gmail.com Sat Nov 26 09:53:57 2016 From: mobiusklein at gmail.com (Joshua Klein) Date: Sat, 26 Nov 2016 09:53:57 -0500 Subject: [Matplotlib-users] How to draw a collection of oriented triangles ? In-Reply-To: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> References: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> Message-ID: I?ve had great success using PathPatch and AffineTransform for this purpose: from matplotlib import pyplot as pltfrom matplotlib.path import Pathfrom matplotlib.transforms import Affine2Dfrom matplotlib.patches import PathPatch unit_triangle = Path.unit_regular_polygon(3) def make_triangle(x, y, rot_deg, color, scale): path = Path(unit_triangle.vertices * scale, unit_triangle.codes) trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) t_path = path.transformed(trans) patch = PathPatch(t_path, facecolor=color) return patch ax = plt.gca() for x, y, rot_deg in [(1, 1, 90), (2, 2, 45), (-1, 1, 128)]: patch = make_triangle(x, y, rot_deg, "blue", 1) ax.add_patch(patch) # Patches don't automatically change the visible range of the axes like scatter does. ax.autoscale() ? On Sat, Nov 26, 2016 at 9:21 AM, Nicolas P. Rougier < Nicolas.Rougier at inria.fr> wrote: > > I would like to draw several triangles (same size, same color) with > different individual orientations. > Scatter plot does not allow to specify individual orientations and I've a > hard time with PatchCollection. > > What would be the easiest way ? Is there an example somewhere around by > any chance ? > > > Nicolas > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Nicolas.Rougier at inria.fr Sat Nov 26 12:20:34 2016 From: Nicolas.Rougier at inria.fr (Nicolas P. Rougier) Date: Sat, 26 Nov 2016 18:20:34 +0100 Subject: [Matplotlib-users] How to draw a collection of oriented triangles ? In-Reply-To: References: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> Message-ID: <17E2FE84-1215-4A01-96DB-A0F401CA0586@inria.fr> Thank you Joshua, I'll start from your code. My other problem is that I also need to update rotation and position (for an animation). Hope this will work with patch collection and updating individual transform. Nicolas > On 26 Nov 2016, at 15:53, Joshua Klein wrote: > > I?ve had great success using PathPatch and AffineTransform for this purpose: > > from matplotlib import pyplot as > plt > > from matplotlib.path import > Path > > from matplotlib.transforms import > Affine2D > > from matplotlib.patches import > PathPatch > > unit_triangle = Path.unit_regular_polygon( > 3 > ) > > > def make_triangle(x, y, rot_deg, color, scale): > > path = Path(unit_triangle.vertices * scale, unit_triangle.codes) > trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) > t_path = path.transformed(trans) > patch = PathPatch(t_path, facecolor=color) > > return > patch > > ax = plt.gca() > > > for x, y, rot_deg in [(1, 1, 90), (2, 2, 45), (-1, 1, 128 > )]: > patch = make_triangle(x, y, rot_deg, > "blue", 1 > ) > ax.add_patch(patch) > > > # Patches don't automatically change the visible range of the axes like scatter does. > > ax.autoscale() > > > On Sat, Nov 26, 2016 at 9:21 AM, Nicolas P. Rougier wrote: > > I would like to draw several triangles (same size, same color) with different individual orientations. > Scatter plot does not allow to specify individual orientations and I've a hard time with PatchCollection. > > What would be the easiest way ? Is there an example somewhere around by any chance ? > > > Nicolas > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From mobiusklein at gmail.com Sat Nov 26 15:47:35 2016 From: mobiusklein at gmail.com (Joshua Klein) Date: Sat, 26 Nov 2016 15:47:35 -0500 Subject: [Matplotlib-users] How to draw a collection of oriented triangles ? In-Reply-To: <17E2FE84-1215-4A01-96DB-A0F401CA0586@inria.fr> References: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> <17E2FE84-1215-4A01-96DB-A0F401CA0586@inria.fr> Message-ID: I don?t think my code ever directly works with a PatchCollection object, just individual patches which possess distinct properties. Here?s an example using animations: import matplotlib matplotlib.use("Tkagg")from matplotlib import pyplot as pltfrom matplotlib.path import Pathfrom matplotlib.transforms import Affine2Dfrom matplotlib.patches import PathPatchfrom matplotlib import animationimport numpy as np unit_triangle = Path.unit_regular_polygon(3) def make_triangle(x, y, rot_deg, color, scale): path = Path(unit_triangle.vertices * scale, unit_triangle.codes) trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) t_path = path.transformed(trans) patch = PathPatch(t_path, facecolor=color) return patch triangles = [(1, 1, 90), (2, 2, 45), (-1, 1, 128)] patches = [] def step_fn(i): next_step = [] # Random walk update each triangle's position for tri in triangles: x = tri[0] + np.random.random() - 0.5 y = tri[1] + np.random.random() - 0.5 rot = tri[2] + (np.random.random() - 0.5) * 45 next_step.append((x, y, rot)) triangles[:] = next_step # Remove the old patches while patches: patch = patches.pop() patch.remove() # Add the new patches patches[:] = [make_triangle(x, y, rot_deg, "blue", 0.2) for x, y, rot_deg in triangles] for patch in patches: plt.gca().add_patch(patch) plt.autoscale() fig = plt.figure() a = animation.FuncAnimation(fig, step_fn, blit=False, interval=10) plt.show() ? On Sat, Nov 26, 2016 at 12:20 PM, Nicolas P. Rougier < Nicolas.Rougier at inria.fr> wrote: > > Thank you Joshua, I'll start from your code. My other problem is that I > also need to update rotation and position (for an animation). Hope this > will work with patch collection and updating individual transform. > > Nicolas > > > On 26 Nov 2016, at 15:53, Joshua Klein wrote: > > > > I?ve had great success using PathPatch and AffineTransform for this > purpose: > > > > from matplotlib import pyplot as > > plt > > > > from matplotlib.path import > > Path > > > > from matplotlib.transforms import > > Affine2D > > > > from matplotlib.patches import > > PathPatch > > > > unit_triangle = Path.unit_regular_polygon( > > 3 > > ) > > > > > > def make_triangle(x, y, rot_deg, color, scale): > > > > path = Path(unit_triangle.vertices * scale, unit_triangle.codes) > > trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) > > t_path = path.transformed(trans) > > patch = PathPatch(t_path, facecolor=color) > > > > return > > patch > > > > ax = plt.gca() > > > > > > for x, y, rot_deg in [(1, 1, 90), (2, 2, 45), (-1, 1, 128 > > )]: > > patch = make_triangle(x, y, rot_deg, > > "blue", 1 > > ) > > ax.add_patch(patch) > > > > > > # Patches don't automatically change the visible range of the axes like > scatter does. > > > > ax.autoscale() > > > > > > On Sat, Nov 26, 2016 at 9:21 AM, Nicolas P. Rougier < > Nicolas.Rougier at inria.fr> wrote: > > > > I would like to draw several triangles (same size, same color) with > different individual orientations. > > Scatter plot does not allow to specify individual orientations and I've > a hard time with PatchCollection. > > > > What would be the easiest way ? Is there an example somewhere around by > any chance ? > > > > > > Nicolas > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Nicolas.Rougier at inria.fr Sun Nov 27 02:34:59 2016 From: Nicolas.Rougier at inria.fr (Nicolas P. Rougier) Date: Sun, 27 Nov 2016 08:34:59 +0100 Subject: [Matplotlib-users] How to draw a collection of oriented triangles ? In-Reply-To: References: <11FA6096-984F-4AAD-B724-E18BB9CBC441@inria.fr> <17E2FE84-1215-4A01-96DB-A0F401CA0586@inria.fr> Message-ID: <7B256CDD-FC26-41F6-9E85-D2CDDAB31FBE@inria.fr> Thanks. I end up using a PathCollection with a single path. The advantage is that you can split a path into several disconnected paths but the update can still be made at once (scaling, translating and rotation). This makes things relatively fast. Code is available at: https://gist.github.com/rougier/b82fe08f1840f4277b52fb8bfbdb3cc7 Nicolas > On 26 Nov 2016, at 21:47, Joshua Klein wrote: > > I don?t think my code ever directly works with a PatchCollection object, just individual patches which possess distinct properties. Here?s an example using animations: > > import > matplotlib > matplotlib.use( > "Tkagg" > ) > > from matplotlib import pyplot as > plt > > from matplotlib.path import > Path > > from matplotlib.transforms import > Affine2D > > from matplotlib.patches import > PathPatch > > from matplotlib import > animation > > import numpy as > np > > unit_triangle = Path.unit_regular_polygon( > 3 > ) > > > def make_triangle(x, y, rot_deg, color, scale): > > path = Path(unit_triangle.vertices * scale, unit_triangle.codes) > trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) > t_path = path.transformed(trans) > patch = PathPatch(t_path, facecolor=color) > > return > patch > > triangles = [( > 1, 1, 90), (2, 2, 45), (-1, 1, 128 > )] > patches = [] > > > def step_fn(i): > > next_step = [] > > # Random walk update each triangle's position > > > for tri in > triangles: > x = tri[ > 0] + np.random.random() - 0.5 > > y = tri[ > 1] + np.random.random() - 0.5 > > rot = tri[ > 2] + (np.random.random() - 0.5) * 45 > > next_step.append((x, y, rot)) > triangles[:] = next_step > > > # Remove the old patches > > > while > patches: > patch = patches.pop() > patch.remove() > > > # Add the new patches > > patches[:] = [make_triangle(x, y, rot_deg, > "blue", 0.2) for x, y, rot_deg in > triangles] > > for patch in > patches: > plt.gca().add_patch(patch) > plt.autoscale() > > fig = plt.figure() > a = animation.FuncAnimation(fig, step_fn, blit= > False, interval=10 > ) > > plt.show() > > > On Sat, Nov 26, 2016 at 12:20 PM, Nicolas P. Rougier wrote: > > Thank you Joshua, I'll start from your code. My other problem is that I also need to update rotation and position (for an animation). Hope this will work with patch collection and updating individual transform. > > Nicolas > > > On 26 Nov 2016, at 15:53, Joshua Klein wrote: > > > > I?ve had great success using PathPatch and AffineTransform for this purpose: > > > > from matplotlib import pyplot as > > plt > > > > from matplotlib.path import > > Path > > > > from matplotlib.transforms import > > Affine2D > > > > from matplotlib.patches import > > PathPatch > > > > unit_triangle = Path.unit_regular_polygon( > > 3 > > ) > > > > > > def make_triangle(x, y, rot_deg, color, scale): > > > > path = Path(unit_triangle.vertices * scale, unit_triangle.codes) > > trans = Affine2D().translate(x, y).rotate_deg_around(x, y, rot_deg) > > t_path = path.transformed(trans) > > patch = PathPatch(t_path, facecolor=color) > > > > return > > patch > > > > ax = plt.gca() > > > > > > for x, y, rot_deg in [(1, 1, 90), (2, 2, 45), (-1, 1, 128 > > )]: > > patch = make_triangle(x, y, rot_deg, > > "blue", 1 > > ) > > ax.add_patch(patch) > > > > > > # Patches don't automatically change the visible range of the axes like scatter does. > > > > ax.autoscale() > > > > > > On Sat, Nov 26, 2016 at 9:21 AM, Nicolas P. Rougier wrote: > > > > I would like to draw several triangles (same size, same color) with different individual orientations. > > Scatter plot does not allow to specify individual orientations and I've a hard time with PatchCollection. > > > > What would be the easiest way ? Is there an example somewhere around by any chance ? > > > > > > Nicolas > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users at python.org > > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > From efiring at hawaii.edu Sun Nov 27 03:00:57 2016 From: efiring at hawaii.edu (Eric Firing) Date: Sat, 26 Nov 2016 22:00:57 -1000 Subject: [Matplotlib-users] how to create a double-sided arrow of arbitrary width with matplotlib's annotate(...) method? In-Reply-To: References: Message-ID: Tanim, I haven't seen any replies on the list; did you get replies directly to yourself? If there is already a good answer to your question, please forward it to the list in case someone else searches for the same thing. I'm not sure exactly what you are looking for. Maybe if you show the result of your "hack" it would be clear. Did you try using something like arrowstyle="fancy,head_length=0.4,head_width=0.4,tail_width=0.4" as an entry in the arrowprops dict keyword argument to annotate? That lets you control the width. See http://matplotlib.org/examples/pylab_examples/annotation_demo2.html. Eric On 2016/11/24 10:34 AM, Tanim Islam wrote: > Hello, > > Does anyone have a one-method annotate(...) example to create a > double-sided arrow, of arbitrary width? I was able to do so but only by > hacking together two one-sided annotate(...) methods. > > Tanim Islam From james.c.brenton at nasa.gov Wed Nov 9 17:13:16 2016 From: james.c.brenton at nasa.gov (jcb0026) Date: Wed, 09 Nov 2016 22:13:16 -0000 Subject: [Matplotlib-users] ImportError: cannot import name '_tkagg' Message-ID: <1478729595515-47619.post@n5.nabble.com> Greetings, I'm trying to run a Python script that uses tkinter to create a GUI and matplotlib to display a graph onto the GUI. Our System Administrators installed Python 3.5, tkinter, and matplotlib onto a Redhat Linux 7.2 machine. Within the code of our script, to import all necessary matplotlib functions and modules, we call: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure import matplotlib matplotlib.use('TkAgg') However, when the script is ran, this is the result: File "ourScript.py", line 17, in from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg File "/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 11, in import matplotlib.backends.tkagg as tkagg File "/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/matplotlib/backends/tkagg.py", line 2, in from matplotlib.backends import _tkagg ImportError: cannot import name '_tkagg' After doing some research, it seems that this could be due to matplotlib being installed before tkinter. Is this likely the case? Thanks, James -- View this message in context: http://matplotlib.1069221.n5.nabble.com/ImportError-cannot-import-name-tkagg-tp47619.html Sent from the matplotlib - users mailing list archive at Nabble.com. From jonathan.dan at byteflies.com Sat Nov 12 12:35:49 2016 From: jonathan.dan at byteflies.com (Jonathan Dan) Date: Sat, 12 Nov 2016 17:35:49 -0000 Subject: [Matplotlib-users] Blit: previous frames not cleared Message-ID: <86fe7ad7-3a85-b01a-a788-9af361019653@byteflies.com> Hello I am trying to use the animation tools of matplotlib. When I update the Axes some previous frames are not properly cleared. What am I doing wrong? Here is a minimum working example #!/usr/bin/python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GLib from matplotlib.figure import Figure from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas import numpy as np # Update plot def plot_update(ax, background, canvas, fig, line): global t t += 0.1 x = np.linspace(t, 2*np.pi+t, 500) y = np.sin(x) try: canvas.restore_region(background) line.set_ydata(y) ax.draw_artist(line) canvas.blit(ax.bbox) except AttributeError: line, = ax.plot(y, animated=True) canvas.draw() background = canvas.copy_from_bbox(ax.bbox) return True main_window = Gtk.Window() main_window.connect("delete-event", Gtk.main_quit) # Initial data t = 0 x = np.linspace(0, 2*np.pi, 500) y = np.sin(x) # Add figure to Window fig = Figure(figsize=(5,5), dpi=96) ax = fig.add_subplot(111) line, = ax.plot(y, animated=True) canvas = FigureCanvas(fig) canvas.set_size_request(400,400) canvas.draw() background = canvas.copy_from_bbox(ax.bbox) main_window.add(canvas) main_window.show_all() GLib.timeout_add(200, plot_update, ax, background, canvas, fig, line) Gtk.main() Thank you Jonathan From asafeilam at gmail.com Mon Nov 14 07:35:35 2016 From: asafeilam at gmail.com (asaf) Date: Mon, 14 Nov 2016 12:35:35 -0000 Subject: [Matplotlib-users] interactive plot matplotlib Message-ID: <1479126934743-47621.post@n5.nabble.com> hi, I'm trying to display figures on demand by input command, however the figure isn't displayed and it becomes non_responding object. the code is given below : plt.close() fig = plt.figure() plt.subplot(211) plt.plot(t/24,ys) plt.hold('True') # plt.plot(t/24,dend_value[:K2,K1]) plt.plot(t/24,raw) plt.hold('True') plt.plot(t[-24:]/24,raw[-24:],color='r',lw=2) plt.title([decision,dend_flat.mean()+3*x1]) plt.subplot(212) plt.plot(t/24,STD_) plt.hold('True') plt.plot(t/24,FLAT_Sig) plt.hold('True') plt.plot(t/24,num_of_sigma*STD2_) input('press enter') I don't want to use waitforbuttonpress() because I want to play with the figure before continuation. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/interactive-plot-matplotlib-tp47621.html Sent from the matplotlib - users mailing list archive at Nabble.com. From lara.4884 at gmail.com Fri Nov 18 01:18:43 2016 From: lara.4884 at gmail.com (lara) Date: Fri, 18 Nov 2016 06:18:43 -0000 Subject: [Matplotlib-users] How to increase space between labels ( x or Y) Message-ID: <1479448985635-47626.post@n5.nabble.com> My y labels are variables ( eg. name1, nam2, nam3,...) How to increase space between name1 and name2 in yaxis since name1 and name2 are overlaping with each other note I have already 25 labels so assigned each 1 space for 25 variables in the yaxis , I dont want to alter anyting in the scale but want to make more space between labels so it wont overlap thanks in advance -- View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-increase-space-between-labels-x-or-Y-tp47626.html Sent from the matplotlib - users mailing list archive at Nabble.com. From llacque at gmail.com Thu Nov 3 22:38:47 2016 From: llacque at gmail.com (Jack Yu) Date: Fri, 04 Nov 2016 02:38:47 -0000 Subject: [Matplotlib-users] How to apply ax.margins to current axes limits? Message-ID: Is there a way to use ax.margins to adjust the axes limits, after the axes limits have already been adjusted using ax.set_ylim? It appears that ax.margins has effect only if ax.set_ylim has not been used. This notebook http://nbviewer.jupyter.org/github/qap/python_examples/blob/matplotlib/matplotlib/matplotlib_axmargins.ipynb describes a situation in which this need may arise. Note: the y-axis is just an example, the same also applies to the x-axis ( ax.set_xlim). -------------- next part -------------- An HTML attachment was scrubbed... URL: