From: Phil C. <phi...@an...> - 2015-10-17 00:26:54
|
Wow, that's fantastic Ben. Thanks so much for finding that, it's just what I need! Regards, - Phil Benjamin Root wrote: > Looks like someone else figured out a creative solution using quiver: > http://stackoverflow.com/questions/19918502/sawtooth-line-style-in-matplotlib > > Here it is (slightly cleaned up): > > |import matplotlib.pyplotas plt > import numpyas np > > x= np.linspace(0, 2*np.pi, 100) > y= np.sin(x) > > dx= np.diff(x) > dy= np.diff(y) > > x2= np.linspace(0, 2*np.pi, 10) > y2= np.sin(x2) > > dx= np.zeros_like(x2) + 1e-12 > dy= np.sin(x2+dx) - y2 > > length= np.hypot(dx,dy) > dx/= length > dy/= length > > fig, ax= plt.subplots() > ax.set_aspect("equal") > ax.plot(x, y, lw=4) > > size= 20 > ax.quiver(x2, y2, -dy, dx, headaxislength=size, headlength=size, headwidth=size, color="blue") > plt.margins(0.2)| > > I don't know yet how to get rounded heads, though. Now I am looking to > see how the text box styles of "sawtooth" and "roundtooth" are handled > in the code to see if that could be exploited, instead. > > Cheers! > Ben Root > > > > On Fri, Oct 16, 2015 at 10:24 AM, Benjamin Root <ben...@gm... > <mailto:ben...@gm...>> wrote: > > Hmmm, this is actually an interesting problem. I am also a > meteorologist, so this is interesting to me. > > I haven't figured it out yet, but here are my thoughts: > > 1) There are the "^" triangle markers as well as "2" tri_up > markers: > http://nbviewer.ipython.org/github/WeatherGod/AnatomyOfMatplotlib/blob/master/AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb#Markers > 2) The markevery property should be set to a float value to have > the markers spaced out evenly along the line regardless of aspect > ratios and zooming (note, this assumes that the line is defined > with many vertices to give a smooth appearance). > > Problem: > Using markers and markevery in a Line2D object has an inherent > limitation: all of the markers will be drawn in the same > orientation. So, we can't orient the markers along the normal of > the line. > Also, there is no pre-defined marker for half-circles, so this > approach wouldn't work well for warm-fronts/dry-lines/etc. > > I'll have to see if a PolygonCollection + Line2D might be the > right approach here... > > Ben Root > > > > > On Fri, Oct 16, 2015 at 7:22 AM, Phil Cummins > <phi...@an... <mailto:phi...@an...>> wrote: > > Hi, > > I would like to plot "toothed" curves using basemap. These are > curves with triangles on one side, that are used to plot > pressure fronts in meteorology or thrust faults in geology. > You need to be able to say which side of the curve the > triangles should appear on. Does anyone know whether such > curves can be plotted using mtplotlib/basemap? > > Thanks, > > - Phil > > Australian National University > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > -- Phil Cummins Prof. Natural Hazards Research School of Earth Sciences Australian National University |