簡體   English   中英

熊貓Matplotlib:如何更改散點圖中圖例的形狀和大小?

[英]Pandas Matplotlib: How to change shape and size of the legend in 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)

我想知道如何將圖例中氣泡的形狀和大小更改為矩形和較小的大小。 有人可以幫忙嗎? 在此處輸入圖片說明

您可以使用markerscale關鍵字更改圖例中符號的大小。 例如,

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

將使符號大小減小2倍。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM