2017-08-11 74 views
3

我需要在地圖上繪製數據站點。例如,調查「DEPROAS」有五個電臺,所以我需要繪製並插入圖例指南。但是,當我這樣做時,不是隻繪製一次(代表這五個臺),而是繪製五個點。任何想法?圖和下面的代碼。圖例標記出現多次

  #### DEPROAS #### - Cabo Frio 

      fcf1=[-22-(59.030/60),-42-(07.340/60)] 
      fcf2=[-23-(05.444/60),-41-(54.700/60)] 
      fcf=[fcf1,fcf2] 
      fcf=np.array(fcf) 
      lat_fcf = fcf[0:len(fcf),0] 
      lon_fcf = fcf[0:len(fcf),1] 
      x_fcf,y_fcf=m(lon_fcf,lat_fcf) 

      plt.plot(x_fcf[0],y_fcf[0], 'o', label='DEPROAS', color='#88ff4d', zorder = 3000) 
      plt.plot(x_fcf[1],y_fcf[1], 'o', label='DEPROAS', color='#88ff4d', zorder = 3000) 

      #### DEPROAS #### - Ubatuba 
      fub1=[-23-(43.560/60),-44-(53.860/60)] 
      fub2=[-24-(04.028/60),-44-(39.005/60)] ##rever nos dados no lab 
      fub=[fub1,fub2] 
      fub=np.array(fub) 
      lat_fub = fub[0:len(fub),0] 
      lon_fub = fub[0:len(fub),1] 
      x_fub,y_fub=m(lon_fub,lat_fub) 

      plt.plot(x_fub[0],y_fub[0], 'o', label = 'DEPROAS', color='#88ff4d', zorder = 3000) 
      plt.plot(x_fub[1],y_fub[1], 'o', label = 'DEPROAS', color='#88ff4d', zorder = 3000) 

      #### DEPROAS #### - Guanabara 

      fbg1=[-23-(18.34/60),-42-(45.81/60)] 
      fbg=[fbg1] 
      fbg=np.array(fbg) 
      lat_fbg = fbg[0:len(fbg),0] 
      lon_fbg = fbg[0:len(fbg),1] 
      x_fbg,y_fbg=m(lon_fbg,lat_fbg) 

      plt.plot(x_fbg[0],y_fbg[0], 'o', label = 'DEPROAS', color='#88ff4d', zorder = 3000) 

回答

2

您繪製了標籤爲「DEPROAS」的5個系列,因此您的圖例中包含所有這些標記和標籤的5個條目。

根據legend guide你必須構建自定義圖例,並把所有需要的系列列表,並在傳說繪製它:

... 
series1, = plt.plot(x_fub[0],y_fub[0], 'o', label = 'DEPROAS', color='#88ff4d', zorder = 3000) 
plt.plot(x_fub[1],y_fub[1], 'o', label = 'DEPROAS', color='#88ff4d', zorder = 3000) 

# make custom legend for series1 
plt.legend(handles=[series1], loc=2) 
... 
+0

它的工作!謝謝你,寧靜! –