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

how to include diferrent swing items to main class from another class

java swing

I am quite new to java. I have created a GUI window with some jlabel , jtextfield. But recently for a project I need to create another class with those jlabel and jtextfield and need to display the...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.