diff --git a/doc/使用说明.docx b/doc/使用说明.docx new file mode 100644 index 0000000..11d442c Binary files /dev/null and b/doc/使用说明.docx differ diff --git a/git.txt b/git.txt new file mode 100644 index 0000000..cdb54bf --- /dev/null +++ b/git.txt @@ -0,0 +1,4 @@ +git show +111 +333 + diff --git a/src/mycode.py b/src/mycode.py new file mode 100644 index 0000000..7ac4705 --- /dev/null +++ b/src/mycode.py @@ -0,0 +1,52 @@ +import matplotlib.pyplot as plt +import matplotlib.font_manager as fm + +# ½ø¼ÛÓëÁãÊÛ¼Û +basePrice, salePrice = 49, 75 + +# ¼ÆËãÂònum¸öʱµÄÅú·¢¼Û£¬ÂòµÄÔ½¶à£¬µ¥¼ÛÔ½µÍ +def compute(num): + return salePrice * (1-0.01*num) + +# numbersÓÃÀ´´æ´¢¹Ë¿Í¹ºÂòÊýÁ¿ +# earnsÓÃÀ´´æ´¢É̳¡µÄÓ¯ÀûÇé¿ö +# totalConsumptionÓÃÀ´´æ´¢¹Ë¿ÍÏû·Ñ×ܽð¶î +# savesÓÃÀ´´æ´¢¹Ë¿Í½ÚÊ¡µÄ×ܽð¶î +numbers = list(range(1, 31)) +earns = [] +totalConsumption = [] +saves = [] +# ¸ù¾Ý¹Ë¿Í¹ºÂòÊýÁ¿¼ÆËãÈý×éÊý¾Ý +for num in numbers: + earns.append(round(num*(compute(num)-basePrice), 2)) + totalConsumption.append(round(num*compute(num), 2)) + saves.append(round(num*(salePrice-compute(num)), 2)) + +# »æÖÆÉ̼ÒÓ¯ÀûºÍ¹Ë¿Í½ÚÊ¡µÄÕÛÏßͼ£¬ÏµÍ³×Ô¶¯·ÖÅäÏßÌõÑÕÉ« +plt.plot(numbers, earns, label='É̼ÒÓ¯Àû') +plt.plot(numbers, totalConsumption, label='¹Ë¿Í×ÜÏû·Ñ', ls='-.') +plt.plot(numbers, saves, label='¹Ë¿Í½ÚÊ¡', lw=3) + +# ÉèÖÃ×ø±êÖáÎı¾ +plt.xlabel('¹Ë¿Í¹ºÂòÊýÁ¿£¨¼þ£©', fontproperties='simhei') +plt.ylabel('½ð¶î£¨Ôª£©', fontproperties='simhei') +# ÉèÖÃͼÐαêÌâ +plt.title('ÊýÁ¿-½ð¶î¹Øϵͼ', fontproperties='stkaiti') + +# ´´½¨×ÖÌ壬ÉèÖÃͼÀý +myfont = fm.FontProperties(fname=r'C:\Windows\Fonts\STKAITI.ttf') +plt.legend(prop=myfont) + +# ¼ÆËã²¢±ê¼ÇÉ̼ÒÓ¯Àû×î¶àµÄÅú·¢ÊýÁ¿ +maxEarn = max(earns) +bestNumber = numbers[earns.index(maxEarn)] +# É¢µãͼ£¬ÔÚÏàӦλÖûæÖÆÒ»¸öºìÉ«Îå½ÇÐÇ£¬Ïê¼û8.3½Ú +plt.scatter([bestNumber], [maxEarn], marker='*', color='red', s=120) +# ʹÓÃÎı¾±ê×¢±ê¼Ç¸ÃλÖà +plt.annotate(xy=(bestNumber, maxEarn), # ¼ýÍ·ÖÕµã + xytext=(bestNumber-1, maxEarn+200),# ¼ýÍ·Æðµã + s=str(maxEarn), # ÏÔʾµÄ±ê×¢Îı¾ + arrowprops=dict(arrowstyle="->")) # ¼ýÍ·Ñùʽ + +# ÏÔʾͼÐÎ +plt.show()