From Randall.Benson at avangrid.com Wed Apr 1 16:18:43 2020 From: Randall.Benson at avangrid.com (Benson, Randall) Date: Wed, 1 Apr 2020 20:18:43 +0000 Subject: [Matplotlib-users] Adding 2 Data Array's Math Operation Message-ID: Hi - I'm struggling to figure out why I am not receiving the result from trying to add 2 unique but with same shape DataArrays that look like this below: dask.array Coordinates: * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0 * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 month int64 2 * variable (variable) speedc = np.sqrt(uwindc*uwindc+vwindc*vwindc) Gives me an empty (when I try speedc.plot()) variable that looks like this below: speedc Out[219]: dask.array Coordinates: * variable (variable) object * lat (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0 * lon (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5 month int64 2 Thank you for any help that you can provide after I've exhausted my search (I must be missing something). Randall [Description: cid:image001.jpg at 01D34737.23261CB0] Randall P. Benson, PhD Wind Asset Meteorologist, Energy Resource - Onshore 1125 NW Couch Street, Suite 700 Portland, Oregon, USA 97209 Telephone 503-796-7129 Cell 971-227-2477 randall.benson at avangrid.com [Description: cid:image002.png at 01D34737.23261CB0] In the interest of the environment, please print only if necessary and recycle. ============================================================== Please consider the environment before printing this email. If you have received this message in error, please notify the sender and immediately delete this message and any attachment hereto and/or copy hereof, as such message contains confidential information intended solely for the individual or entity to whom it is addressed. The use or disclosure of such information to third parties is prohibited by law and may give rise to civil or criminal liability. The views presented in this message are solely those of the author(s) and do not necessarily represent the opinion of Avangrid Renewables, LLC. or any company of its group. Neither Avangrid Renewables, LLC. nor any company of its group guarantees the integrity, security or proper receipt of this message. Likewise, neither Avangrid Renewables, LLC. nor any company of its group accepts any liability whatsoever for any possible damages arising from, or in connection with, data interception, software viruses or manipulation by third parties. ============================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 45526 bytes Desc: image001.jpg URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 3441 bytes Desc: image002.png URL: From x.piter at gmail.com Thu Apr 2 14:53:01 2020 From: x.piter at gmail.com (Piter_) Date: Thu, 2 Apr 2020 20:53:01 +0200 Subject: [Matplotlib-users] position of level label. Message-ID: Hi everyone. Is it possible to set position of level labels in contour plot? https://matplotlib.org/3.1.0/gallery/images_contours_and_fields/contour_label_demo.html# Thanks. Petro. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Fri Apr 3 16:11:29 2020 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 3 Apr 2020 16:11:29 -0400 Subject: [Matplotlib-users] scatter c=colors seems confusing and inconsistent Message-ID: For 2d scatter, I can pass 2d arrays as X and Y. But it seems not c=. Here is a demonstration: ------------ import matplotlib.pyplot as plt import numpy as np A = np.array import colorcet as cc cmap = cc.m_rainbow x = A([[0,.25], [0.5, 0.75]]) y = x**2 colors = np.empty (x.shape, dtype=object) for i in range(2): for j in range(2): colors[i,j] = cmap(x[i,j]) plt.scatter (x, y, c=colors.flatten()) -------------- Without colors.flatten(), mpl will give an error. It seems to be OK with X and Y being 2D, but not c. In this example I have given c as a 2d array of objects, each object being an RGBA tuple. Is there an easier way? Preferably one that doesn't require me to specifically allocate an empty array of objects and then populate it with an explicit loop? -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Fri Apr 3 16:39:56 2020 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 3 Apr 2020 10:39:56 -1000 Subject: [Matplotlib-users] scatter c=colors seems confusing and inconsistent In-Reply-To: References: Message-ID: <3b53689e-38ab-5587-8222-86fc10b80daa@hawaii.edu> Neal, You can use the built-in color-mapping, like this: import matplotlib.pyplot as plt import numpy as np A = np.array import colorcet as cc cmap = cc.m_rainbow x = A([[0,.25], [0.5, 0.75]]) y = x**2 plt.scatter (x, y, c=x, cmap=cmap) ------- Eric On 2020/04/03 10:11 AM, Neal Becker wrote: > import matplotlib.pyplot as plt > import numpy as np > A = np.array > > import colorcet as cc > cmap = cc.m_rainbow > > x = A([[0,.25], [0.5, 0.75]]) > y = x**2 > colors = np.empty (x.shape, dtype=object) > for i in range(2): > ? ? for j in range(2): > ? ? ? ? colors[i,j] = cmap(x[i,j]) > > plt.scatter (x, y, c=colors.flatten()) From efiring at hawaii.edu Sat Apr 4 02:59:23 2020 From: efiring at hawaii.edu (Eric Firing) Date: Fri, 3 Apr 2020 20:59:23 -1000 Subject: [Matplotlib-users] Connect plot in Contourf when there are missing values(nan) In-Reply-To: <1582184535596-0.post@n5.nabble.com> References: <1582184535596-0.post@n5.nabble.com> Message-ID: I just found this unread in my email stack--did anyone reply to you already? If not, the answer to your question is no, matplotlib declines to fill bad value gaps via interpolation. We believe that as a plotting library, we should generally plot the data as provided, leaving it to the user to interpolate over gaps, if that is desired. Eric On 2020/02/19 9:42 PM, apu wrote: > I am plotting x, y, z values using contourf plots. However I have some > missing z values (nan). All these regions are shown as blanks and the graph > looks diconnected. > > Is there a way for the plot to have connected gaps? Plotly has an option to > connect gaps with smooth transitions? > https://plot.ly/python/contour-plots/#connect-the-gaps-between-none-values-in-the-z-matrix > > Do we have an equivalent of this in matlotlib contourf plots? > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From bret.foreman at gmail.com Wed Apr 15 11:42:24 2020 From: bret.foreman at gmail.com (Bret Foreman) Date: Wed, 15 Apr 2020 08:42:24 -0700 Subject: [Matplotlib-users] continuous plotting with mplot3d Message-ID: I'm using Python 2.7 on Windows 10 in a Jupyter Notebook. I have an external orientation sensor on a USB port. I want to periodically poll that sensor at around 10Hz and update the orientation of a figure on the screen with each new sample. The sensor returns a quaternion when polled which I convert to a rotation matrix to rotate a 3D image array. This all works fine. My problem is getting mplot3d to update the displayed image dynamically after each orientation sample. All I can get is a plot at the end of the run, nothing updates while I'm sampling. How can I change this code to plot dynamically? Here's my code: *import serial.tools.list_ports # import serial moduleimport threespace_api_mod_Bret as ts_apiimport numpy as npimport quaternionimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dimport timedef pack_quat_3space_array( array ): return np.quaternion( array[3] , array[0] , array[1] , array[2] )class SensorAnimation( object ): def __init__(self,commport): # Create 3D axis self.fig = plt.figure() self.ax = self.fig.add_subplot(111, projection='3d') # Initialize the 3space sensor self.sensor = ts_api.TSUSBSensor(commport) #create the 3d image to rotate zline = np.linspace(0, 15, 1000) xline = np.sin(zline) yline = np.cos(zline) # Put the 3d data into an array for rotation self.image_array = np.array([xline,yline,zline]) # Draw the initial image self.ax.plot3D(xline, yline, zline, 'red') # plt.show(block=False) def RefreshPosition( self , previous ): if self.sensor is not None: rot_matrix = quaternion.as_rotation_matrix(pack_quat_3space_array(sensor.getTaredOrientationAsQuaternion())) result = np.dot(rot_matrix,self.image_array) if previous is not None: try: plt.cla() except Exception as e: print(e) previous = self.ax.plot3D(result[0], result[1], result[2], 'green') # plt.pause(0.00001) return previous def Close( self ): if self.sensor is not None: self.sensor.close()try: # Set up animation object sanimate = SensorAnimation("COM5") previous = None for i in range(20): previous = sanimate.RefreshPosition( previous ) time.sleep(0.1) sanimate.Close()* -- Bret Foreman 415-608-0604 -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas_schn at web.de Wed Apr 22 04:33:26 2020 From: andreas_schn at web.de (Andreas Schneider) Date: Wed, 22 Apr 2020 10:33:26 +0200 Subject: [Matplotlib-users] Arc and art3d.pathpatch_2d_to_3d Message-ID: <11f783bb-7e00-1614-0acb-24cf57c9c14e@web.de> Hi, I'm trying to plot an arc in a 3d plot using patches.Arc and art3d.pathpatch_2d_to_3d. However, although the arc is correctly shown from theta1 to theta2 in a 2d plot, the 3d plot always shows the full circle. Here is a minimal example: from matplotlib import pyplot as plt from matplotlib import patches from mpl_toolkits.mplot3d import art3d fig = plt.figure() ax = fig.add_subplot(111, projection='3d') p = patches.Arc((0, 0), 0.5, 0.5, angle=0., theta1=0., theta2=45.) ax.add_patch(p) art3d.pathpatch_2d_to_3d(p, z=0, zdir="y") plt.show() I get a whole circle but want to have an arc only from 0 degrees to 45 degrees. A corresponding 2d plot shows the arc correctly: fig = plt.figure() ax = fig.add_subplot(111) p = patches.Arc((0, 0), 0.5, 0.5, angle=0., theta1=0., theta2=45.) ax.add_patch(p) plt.show() What am I doing wrong with the conversion from 2d to 3d? I tried Python 3.7.3 with Matplotlib 3.0.2 and Python 2.7.16 with Matplotlib 2.2.3 (which are shipped with my Linux distribution). Thanks in advance for your help. Andreas From izabelcvetkovic at gmail.com Wed Apr 22 11:57:51 2020 From: izabelcvetkovic at gmail.com (=?UTF-8?Q?Izabel_Cvetkovi=C4=87?=) Date: Wed, 22 Apr 2020 17:57:51 +0200 Subject: [Matplotlib-users] import problems matplotlib.transforms, matplotlib.numerix Message-ID: Hi all, I am having troubles importing from matplotlib.transforms, specifically the Value and Point methods. Other than that I cannot import matplotlib.numerix, the error message is: no module named 'matplotlib.numerix'. Now, I assume that this has to do with the matplotlib version, as I am using the latest version, and when I checked, there are indeed no 'Value' and 'Point' methods in the transforms module. Does anyone know how this changed with versions and which version should I use to successfully import these modules? Best wishes; Izabel -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Wed Apr 22 12:55:16 2020 From: efiring at hawaii.edu (Eric Firing) Date: Wed, 22 Apr 2020 06:55:16 -1000 Subject: [Matplotlib-users] import problems matplotlib.transforms, matplotlib.numerix In-Reply-To: References: Message-ID: Izabel, You must be trying to run some extremely old code, more than 12 years old. Value and Point date back to the earliest days of mpl (the original _transforms.cpp written by John Hunter), and the numerix module was a compatibility shim for supporting the original Numeric and numarray, which were made obsolete by numpy. (I removed numerix in 2010; it had been deprecated for 17 months.) Eric On 2020/04/22 5:57 AM, Izabel Cvetkovi? wrote: > Hi all, > > I am having troubles importing from matplotlib.transforms, specifically > the Value and Point methods. Other than that I cannot import > matplotlib.numerix, the error message is: no module named > 'matplotlib.numerix'. Now, I assume that this has to do with the > matplotlib version, as I am using the latest version, and when I > checked, there are indeed no 'Value' and 'Point' methods in the > transforms module. > > Does anyone know how this changed with versions and which version should > I use to successfully?import these modules? > > Best wishes; > Izabel > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From tcaswell at gmail.com Wed Apr 22 13:16:07 2020 From: tcaswell at gmail.com (Thomas Caswell) Date: Wed, 22 Apr 2020 13:16:07 -0400 Subject: [Matplotlib-users] Arc and art3d.pathpatch_2d_to_3d In-Reply-To: <11f783bb-7e00-1614-0acb-24cf57c9c14e@web.de> References: <11f783bb-7e00-1614-0acb-24cf57c9c14e@web.de> Message-ID: This is because `Arc` has a lot of logic in it's `draw` method to make sure that the arcs draw correctly and efficiently even if you are zoomed in an a small section, but uses the `Ellipse` patch as it's base (to manage the major/minor axis, location, etc). `Ellipse` works by setting some internal state and then using the draw method from `Patch`. What `art3d.pathpatch_2d_to_3d` does under the hood is change what `__class__` the object thinks it is (!!) and tells your Arc it is now a `Patch3D` and uses the state for the base Path state to draw its self, which due to inheriting from Ellipse is the full ellipse. Having said that, I don't have a good idea of how to fix this. I think the minimal solution is to adjust the path in `Arc` to clip it self to the given range (so the up-convert to Path3D works) and to make sure that the path re-sampling logic in the 2D draw still works on the pre-clipped path. Tom On Wed, Apr 22, 2020 at 4:38 AM Andreas Schneider wrote: > Hi, > > I'm trying to plot an arc in a 3d plot using patches.Arc and > art3d.pathpatch_2d_to_3d. However, although the arc is correctly shown > from theta1 to theta2 in a 2d plot, the 3d plot always shows the full > circle. Here is a minimal example: > > from matplotlib import pyplot as plt > from matplotlib import patches > from mpl_toolkits.mplot3d import art3d > > fig = plt.figure() > ax = fig.add_subplot(111, projection='3d') > p = patches.Arc((0, 0), 0.5, 0.5, angle=0., theta1=0., theta2=45.) > ax.add_patch(p) > art3d.pathpatch_2d_to_3d(p, z=0, zdir="y") > plt.show() > > I get a whole circle but want to have an arc only from 0 degrees to 45 > degrees. A corresponding 2d plot shows the arc correctly: > > fig = plt.figure() > ax = fig.add_subplot(111) > p = patches.Arc((0, 0), 0.5, 0.5, angle=0., theta1=0., theta2=45.) > ax.add_patch(p) > plt.show() > > What am I doing wrong with the conversion from 2d to 3d? > > I tried Python 3.7.3 with Matplotlib 3.0.2 and Python 2.7.16 with > Matplotlib 2.2.3 (which are shipped with my Linux distribution). > > Thanks in advance for your help. > > Andreas > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kees.serier at gmail.com Wed Apr 29 09:53:23 2020 From: kees.serier at gmail.com (Kees Serier) Date: Wed, 29 Apr 2020 15:53:23 +0200 Subject: [Matplotlib-users] subplots and xticklabels Message-ID: Hi, I have been making some graphs with multiple curves with Python 3.7.5 and Matplotlib 3.0.2. Now I want to plot 4 curves in 3 graphs with subplot. This works and the 3 graphs are plotted correctly, including the legends. Only I can't get my X values printed, like I did in my previous graphs with: labels = ax.get_xticklabels() plt.setp(labels, fontsize=6, rotation = 90.) My script is like: ax = plt.axes() name_list = tuple(X) pos_list = np.arange(len(name_list)) ax.xaxis.set_major_locator(ticker.FixedLocator((pos_list))) ax.xaxis.set_major_formatter(ticker.FixedFormatter((name_list))) grid_size = (3,1) fig = plt.figure() plt.subplot2grid(grid_size, (0, 0), rowspan = 1, colspan = 1) plt.plot(pos_list, value_list[0], label = "r/s") plt.plot(pos_list, value_list[1], label = "w/s") plt.title(plt_title) plt.legend(loc = 'lower left', fontsize=6) plt.grid(True) #plt.setp(labels, visible=False) # does not work plt.subplot2grid(grid_size, (1, 0), rowspan = 1, colspan = 1) plt.plot(pos_list, value_list[2], label = "blks/s (kB)") plt.legend(loc = 'lower left', fontsize=6) plt.grid(True) #plt.setp(labels, visible=False) # does not work plt.subplot2grid(grid_size, (2, 0), rowspan = 1, colspan = 1) plt.plot(pos_list, value_list[3], label = "avser (ms)") plt.legend(loc = 'lower left', fontsize=6) labels = ax.get_xticklabels() plt.setp(labels, fontsize=6, rotation = 90.) fig.subplots_adjust(hspace=0) plt.grid(True) plt.show() I have tried a lot of things, but can't get it working. Thank you in advance, Kees -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre.kjellstrup at gmail.com Sat Apr 11 04:15:08 2020 From: andre.kjellstrup at gmail.com (Andre) Date: Sat, 11 Apr 2020 08:15:08 -0000 Subject: [Matplotlib-users] Third Y axis is like cryptonite to pyplot. Message-ID: <1586592909035-0.post@n5.nabble.com> I modified https://matplotlib.org/3.2.1/gallery/ticks_and_spines/multiple_yaxis_with_spines.html to have a fourth data-set: https://gist.github.com/AndKe/c0c999a22a8daebafb62171b671bf131 With the offset of "1.35" par3.spines["right"].set_position(("axes", 1.35)) One can get a glimpse of that, any less, and it will overlap, and more it will be invisible. changing "right" to "left" does nothing. Also, the resulting spines placement does vary with the width of the window. - wasting more space the wider the window gets. -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From hedy.boujelben at etudiant-enit.utm.tn Mon Apr 20 12:13:06 2020 From: hedy.boujelben at etudiant-enit.utm.tn (Hedy BOUJELBEN) Date: Mon, 20 Apr 2020 16:13:06 -0000 Subject: [Matplotlib-users] Logarithmic scale in 3D surface Message-ID: Hello, I'm mechanical student and i'm using python for a project I don't find the logarithmic scale in python for 3D graphs can you help me please ? -------------- next part -------------- An HTML attachment was scrubbed... URL: