|
From: Diego A. <die...@gm...> - 2014-12-05 10:43:07
|
Dear matplotlib users, I would like to know if there is in matplotlib the following Matlab function: *p=patch(x(TRI'),y(TRI'),u(TRI'),u(TRI'));* *set(p,'FaceColor','interp','EdgeColor','black');* where TRI are the coordinate of many non regular rectangles. I would like to do that because I have a not-structured grid whose elements are irregular rectangles. I would like to plot a 3D surface of the values on each points of the grid. Thanks in advance to everyone |
|
From: Sappy85 <rob...@gm...> - 2014-12-05 16:38:59
|
Hi diedro, try something like this: import matplotlib.patches as patches import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) verts = [0.2,0.8], [0.1,0.5], [0.7,0.1] poly = patches.Polygon(verts, ec='r', fc='g') ax.add_patch(poly) plt.show() <http://matplotlib.1069221.n5.nabble.com/file/n44560/help3.png> or this: import numpy as np import matplotlib matplotlib.use('Agg') from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection import matplotlib.pyplot as plt fig, ax = plt.subplots() patches = [] x = np.random.rand(3) y = np.random.rand(3) for i in range(3): polygon = Polygon(np.random.rand(3,2), True) patches.append(polygon) colors = 100*np.random.rand(len(patches)) p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4) p.set_array(np.array(colors)) ax.add_collection(p) plt.colorbar(p) plt.grid() plt.savefig('/var/www/img/help2.png', bbox_inches='tight',pad_inches=0.05) <http://matplotlib.1069221.n5.nabble.com/file/n44560/help2.png> Regards, Sappy85 -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Patch-facecolors-tp44558p44560.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Benjamin R. <ben...@ou...> - 2014-12-05 16:49:11
|
I am a bit confused. Your variable is "TRI", but you keep saying rectangles. You are also referring to unstructured rectangles, which makes zero sense to me. Do you mean triangles? If you, matplotlib has the "tri-" family of functions and a whole module devoted to triangulation-related tasks: http://matplotlib.org/api/tri_api.html http://matplotlib.org/examples/pylab_examples/tricontour_demo.html Even the mplot3d toolkit has (limited) support: http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html I hope that helps! Ben Root On Fri, Dec 5, 2014 at 11:38 AM, Sappy85 <rob...@gm...> wrote: > Hi diedro, > > try something like this: > > import matplotlib.patches as patches > import matplotlib.pyplot as plt > > fig = plt.figure() > ax = fig.add_subplot(111) > verts = [0.2,0.8], [0.1,0.5], [0.7,0.1] > poly = patches.Polygon(verts, ec='r', fc='g') > > ax.add_patch(poly) > plt.show() > > <http://matplotlib.1069221.n5.nabble.com/file/n44560/help3.png> > > or this: > > import numpy as np > import matplotlib > matplotlib.use('Agg') > > from matplotlib.patches import Polygon > from matplotlib.collections import PatchCollection > import matplotlib.pyplot as plt > > fig, ax = plt.subplots() > > patches = [] > x = np.random.rand(3) > y = np.random.rand(3) > > for i in range(3): > polygon = Polygon(np.random.rand(3,2), True) > patches.append(polygon) > > > colors = 100*np.random.rand(len(patches)) > p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4) > p.set_array(np.array(colors)) > ax.add_collection(p) > plt.colorbar(p) > plt.grid() > plt.savefig('/var/www/img/help2.png', bbox_inches='tight',pad_inches=0.05) > > <http://matplotlib.1069221.n5.nabble.com/file/n44560/help2.png> > > Regards, > Sappy85 > > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Patch-facecolors-tp44558p44560.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Diego A. <die...@gm...> - 2014-12-06 16:32:59
|
Dear all, Dear Benjamin, Dear Sappy85, probably I miss the meaning of structured and not-structured grid. In my grid I have only rectangular element, but they are not regular. Here an example. In what follows you can see the x and y vector of the point of one rectangle: X=0.1000 0.5950 0.5659 0.0951 Y=0.0 0.0 0.1839 0.0309 I would like to do as the Ben's example ( http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html), but with non regular rectangles. Moreover, in my my case each point has a different value. Am I asking to much? Thanks Diego On 5 December 2014 at 17:48, Benjamin Root <ben...@ou...> wrote: > I am a bit confused. Your variable is "TRI", but you keep saying > rectangles. You are also referring to unstructured rectangles, which makes > zero sense to me. Do you mean triangles? > > If you, matplotlib has the "tri-" family of functions and a whole module > devoted to triangulation-related tasks: > http://matplotlib.org/api/tri_api.html > http://matplotlib.org/examples/pylab_examples/tricontour_demo.html > > Even the mplot3d toolkit has (limited) support: > http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html > > I hope that helps! > Ben Root > > > On Fri, Dec 5, 2014 at 11:38 AM, Sappy85 <rob...@gm...> wrote: > >> Hi diedro, >> >> try something like this: >> >> import matplotlib.patches as patches >> import matplotlib.pyplot as plt >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> verts = [0.2,0.8], [0.1,0.5], [0.7,0.1] >> poly = patches.Polygon(verts, ec='r', fc='g') >> >> ax.add_patch(poly) >> plt.show() >> >> <http://matplotlib.1069221.n5.nabble.com/file/n44560/help3.png> >> >> or this: >> >> import numpy as np >> import matplotlib >> matplotlib.use('Agg') >> >> from matplotlib.patches import Polygon >> from matplotlib.collections import PatchCollection >> import matplotlib.pyplot as plt >> >> fig, ax = plt.subplots() >> >> patches = [] >> x = np.random.rand(3) >> y = np.random.rand(3) >> >> for i in range(3): >> polygon = Polygon(np.random.rand(3,2), True) >> patches.append(polygon) >> >> >> colors = 100*np.random.rand(len(patches)) >> p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4) >> p.set_array(np.array(colors)) >> ax.add_collection(p) >> plt.colorbar(p) >> plt.grid() >> plt.savefig('/var/www/img/help2.png', bbox_inches='tight',pad_inches=0.05) >> >> <http://matplotlib.1069221.n5.nabble.com/file/n44560/help2.png> >> >> Regards, >> Sappy85 >> >> >> >> >> -- >> View this message in context: >> http://matplotlib.1069221.n5.nabble.com/Patch-facecolors-tp44558p44560.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> >> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
|
From: Benjamin R. <ben...@ou...> - 2014-12-06 23:43:31
|
Well, a rectangle is just two triangles, right? As for each point having a different value, that is not a problem. I would take a good look at the triangulation module. It is design to figure out the triangulations from an arbitrary set of data, or you can specify the triangulations yourself. You can then pass that information into any of the tri-* family of plotting functions. Cheers! Ben Root On Sat, Dec 6, 2014 at 11:32 AM, Diego Avesani <die...@gm...> wrote: > Dear all, Dear Benjamin, Dear Sappy85, > > probably I miss the meaning of structured and not-structured grid. In my > grid I have only rectangular element, but they are not regular. > Here an example. In what follows you can see the x and y vector of the > point of one rectangle: > > X=0.1000 0.5950 0.5659 0.0951 > Y=0.0 0.0 0.1839 0.0309 > > I would like to do as the Ben's example ( > http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html), but with non > regular rectangles. > Moreover, in my my case each point has a different value. > > Am I asking to much? > Thanks > > > Diego > > > On 5 December 2014 at 17:48, Benjamin Root <ben...@ou...> wrote: > >> I am a bit confused. Your variable is "TRI", but you keep saying >> rectangles. You are also referring to unstructured rectangles, which makes >> zero sense to me. Do you mean triangles? >> >> If you, matplotlib has the "tri-" family of functions and a whole module >> devoted to triangulation-related tasks: >> http://matplotlib.org/api/tri_api.html >> http://matplotlib.org/examples/pylab_examples/tricontour_demo.html >> >> Even the mplot3d toolkit has (limited) support: >> http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html >> >> I hope that helps! >> Ben Root >> >> >> On Fri, Dec 5, 2014 at 11:38 AM, Sappy85 <rob...@gm...> wrote: >> >>> Hi diedro, >>> >>> try something like this: >>> >>> import matplotlib.patches as patches >>> import matplotlib.pyplot as plt >>> >>> fig = plt.figure() >>> ax = fig.add_subplot(111) >>> verts = [0.2,0.8], [0.1,0.5], [0.7,0.1] >>> poly = patches.Polygon(verts, ec='r', fc='g') >>> >>> ax.add_patch(poly) >>> plt.show() >>> >>> <http://matplotlib.1069221.n5.nabble.com/file/n44560/help3.png> >>> >>> or this: >>> >>> import numpy as np >>> import matplotlib >>> matplotlib.use('Agg') >>> >>> from matplotlib.patches import Polygon >>> from matplotlib.collections import PatchCollection >>> import matplotlib.pyplot as plt >>> >>> fig, ax = plt.subplots() >>> >>> patches = [] >>> x = np.random.rand(3) >>> y = np.random.rand(3) >>> >>> for i in range(3): >>> polygon = Polygon(np.random.rand(3,2), True) >>> patches.append(polygon) >>> >>> >>> colors = 100*np.random.rand(len(patches)) >>> p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4) >>> p.set_array(np.array(colors)) >>> ax.add_collection(p) >>> plt.colorbar(p) >>> plt.grid() >>> plt.savefig('/var/www/img/help2.png', >>> bbox_inches='tight',pad_inches=0.05) >>> >>> <http://matplotlib.1069221.n5.nabble.com/file/n44560/help2.png> >>> >>> Regards, >>> Sappy85 >>> >>> >>> >>> >>> -- >>> View this message in context: >>> http://matplotlib.1069221.n5.nabble.com/Patch-facecolors-tp44558p44560.html >>> Sent from the matplotlib - users mailing list archive at Nabble.com. >>> >>> >>> ------------------------------------------------------------------------------ >>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >>> with Interactivity, Sharing, Native Excel Exports, App Integration & more >>> Get technology previously reserved for billion-dollar corporations, FREE >>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> >> >> >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> >> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > |