Pandas Matplotlib: How to change shape and size of the legend in scatter plot?

I have a scatter plot :

fig,ax = plt.subplots(figsize=(6,5),dpi=200)

ax.scatter(df1['id'],df1['resellers'],c='red',s=df1['ips']/80,label='AS Size = IPs seen in dnsdb')
ax.set_xticks([1,2,4,6,8,10,12,14,16,18,20])
ax.set_xlim(-1,22)
ax.legend(
       scatterpoints=1,
   loc='best',
   ncol=1,
   fontsize=12)

I am wondering how can I change the shape and size of the bubble in the legend to rectangular and smaller size. Can anybody help?

Answers


You can change the size of the symbol in the legend using the markerscale keyword. For example,

ax.legend(
       scatterpoints=1,
   loc='best',
   ncol=1,
   markerscale=0.5,
   fontsize=12)

will reduce the symbol size by a factor 2.


Need Your Help

Is there a library similar to pyparsing in Java?

java python parsing pyparsing

I need to quickly build a parser for a very simplified version of a html-like markup language in Java. In python, I would use pyparsing library to do this. Is there something similar for Java? Plea...

HTML5 Video is not working with AngularJS ng-src tag

ajax html5 angularjs html5-video

AngularJS ng-src doesn't work with HTML5 Video element in this fiddle: http://jsfiddle.net/FsHah/5/