Legend在Python中无法正常工作

时间:2016-11-09 03:34:49

标签: python graph legend

enter image description here将matplotlib.pyplot导入为plt     导入numpy为np     导入xlrd     import xlwt     将pandas导入为pd

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Something</title>
  <style type="text/css">
    #scrolly {
      width: 100%;
      height: 800px;
      /*overflow: auto;*/
      /*overflow-y: hidden;*/
      margin: 5 auto;
      white-space: nowrap
    }
    .pdfobject-container {
      /*width: 100%;*/
      max-width: 800px;
      height: 800px;
      margin: 5em 0;
      display: inline;
    }
    .pdfobject {
      border: solid 1px #666;
      max-width: 40%;
    }
  </style>
</head>

<body>

  <div id='scrolly'>
    <div id="pdf1">PDF details1</div>
    <div id="pdf2">PDF details2</div>
    <div id="pdf3">PDF details3</div>
  </div>

  <script src="PDFObject-master/pdfobject.js"></script>
  <script

除第一个图例外,图例显示不正确(&#34;更正了T182&#34;)。我尝试了很多方法。我怎么解决这个问题?我在这里附上我的问题图片。我还为您的方便附加了数据文件。提前致谢。 Data file

1 个答案:

答案 0 :(得分:0)

我发现如果我使用Panda来读取xls文件,那么传说就没有问题了。它工作得非常好enter image description here

将matplotlib.pyplot导入为plt     导入numpy为np     将pandas导入为pd     导入数学     import xlwt     import xlrd

x_180=df_180.iloc[:,7]
y_180=df_180.iloc[:,8]

x_181=df_181.iloc[:,7]
y_181=df_181.iloc[:,8]

x_182=df_182.iloc[:,7]
y_182=df_182.iloc[:,8]

x_183=df_183.iloc[:,7]
y_183=df_183.iloc[:,8]

plt.plot(x_180,y_180,"ro", label="T180")
plt.plot(x_181,y_181,"gs", label="T181")
plt.plot(x_182,y_182,"bx", label="T182")

plt.xlabel("x (micron)", size ="18",color ="m")
plt.ylabel("y (micron)", size ="18",color ="m")
plt.title("Scatter plot of two adjacent detector surfaces after translation", size ="18",color ="m")
plt.legend()
plt.show()