This Page

Quick search

"""Reference for filled- and unfilled-marker types included with Matplotlib."""fromsiximportiteritemsimportnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlib.linesimportLine2Dpoints=np.ones(3)# Draw 3 points for each linetext_style=dict(horizontalalignment='right',verticalalignment='center',fontsize=12,fontdict={'family':'monospace'})marker_style=dict(linestyle=':',color='cornflowerblue',markersize=10)defformat_axes(ax):ax.margins(0.2)ax.set_axis_off()defnice_repr(text):returnrepr(text).lstrip('u')defsplit_list(a_list):i_half=len(a_list)//2return(a_list[:i_half],a_list[i_half:])# Plot all un-filled markers# --------------------------fig,axes=plt.subplots(ncols=2)# Filter out filled markers and marker settings that do nothing.# We use iteritems from six to make sure that we get an iterator# in both python 2 and 3unfilled_markers=[mform,funciniteritems(Line2D.markers)iffunc!='nothing'andmnotinLine2D.filled_markers]# Reverse-sort for pretty. We use our own sort key which is essentially# a python3 compatible reimplementation of python2 sort.unfilled_markers=sorted(unfilled_markers,key=lambdax:(str(type(x)),str(x)))[::-1]forax,markersinzip(axes,split_list(unfilled_markers)):fory,markerinenumerate(markers):ax.text(-0.5,y,nice_repr(marker),**text_style)ax.plot(y*points,marker=marker,**marker_style)format_axes(ax)fig.suptitle('un-filled markers',fontsize=14)# Plot all filled markers.# ------------------------fig,axes=plt.subplots(ncols=2)forax,markersinzip(axes,split_list(Line2D.filled_markers)):fory,markerinenumerate(markers):ax.text(-0.5,y,nice_repr(marker),**text_style)ax.plot(y*points,marker=marker,**marker_style)format_axes(ax)fig.suptitle('filled markers',fontsize=14)plt.show()