龙空技术网

基础数学-绘图入门(Python篇)

理思录 951

前言:

当前咱们对“python画图函数”大体比较注重,兄弟们都需要知道一些“python画图函数”的相关知识。那么小编在网摘上收集了一些关于“python画图函数””的相关知识,希望同学们能喜欢,大家快快来学习一下吧!

正弦函数:对边/斜边

余弦函数:临边/斜边

import numpy as np

引入库numpy

import numpy as npX=np.linspace(-2,2,5,endpoint=True)print(X)

X=np.linspace(-2,2,5,endpoint=True)

从-2到2,线性的取5个点

import numpy as npimport matplotlib.pyplot as pltpi=np.piprint(pi)X=np.linspace(0,pi*2,500,endpoint=True)Y=np.sin(X)print(X)print(Y)A=type(X)print(A)plt.plot(X,Y)plt.show()

pi=np.pi 圆周率PI

X=np.linspace(0,pi*2,500,endpoint=True) 从0-2pi,取500点

======================= RESTART: F:/python code02/tu01.py ======================3.141592653589793[0.         0.01259155 0.02518311 0.03777466 0.05036621 0.06295777 0.07554932 0.08814088 0.10073243 0.11332398 0.12591554 0.13850709 0.15109864 0.1636902  0.17628175 0.18887331 0.20146486 0.21405641 0.22664797 0.23923952 0.25183107 0.26442263 0.27701418 0.28960574 0.30219729 0.31478884 0.3273804  0.33997195 0.3525635  0.36515506 0.37774661 0.39033817 0.40292972 0.41552127 0.42811283 0.44070438 0.45329593 0.46588749 0.47847904 0.4910706  0.50366215 0.5162537 0.52884526 0.54143681 0.55402836 0.56661992 0.57921147 0.59180302 0.60439458 0.61698613 0.62957769 0.64216924 0.65476079 0.66735235 0.6799439  0.69253545 0.70512701 0.71771856 0.73031012 0.74290167 0.75549322 0.76808478 0.78067633 0.79326788 0.80585944 0.81845099 0.83104255 0.8436341  0.85622565 0.86881721 0.88140876 0.89400031 0.90659187 0.91918342 0.93177498 0.94436653 0.95695808 0.96954964 0.98214119 0.99473274 1.0073243  1.01991585 1.03250741 1.04509896 1.05769051 1.07028207 1.08287362 1.09546517 1.10805673 1.12064828 1.13323983 1.14583139 1.15842294 1.1710145  1.18360605 1.1961976 1.20878916 1.22138071 1.23397226 1.24656382 1.25915537 1.27174693 1.28433848 1.29693003 1.30952159 1.32211314 1.33470469 1.34729625 1.3598878  1.37247936 1.38507091 1.39766246 1.41025402 1.42284557 1.43543712 1.44802868 1.46062023 1.47321179 1.48580334 1.49839489 1.51098645 1.523578   1.53616955 1.54876111 1.56135266 1.57394422 1.58653577 1.59912732 1.61171888 1.62431043 1.63690198 1.64949354 1.66208509 1.67467664 1.6872682  1.69985975 1.71245131 1.72504286 1.73763441 1.75022597 1.76281752 1.77540907 1.78800063 1.80059218 1.81318374 1.82577529 1.83836684 1.8509584  1.86354995 1.8761415 1.88873306 1.90132461 1.91391617 1.92650772 1.93909927 1.95169083 1.96428238 1.97687393 1.98946549 2.00205704 2.0146486  2.02724015 2.0398317  2.05242326 2.06501481 2.07760636 2.09019792 2.10278947 2.11538103 2.12797258 2.14056413 2.15315569 2.16574724 2.17833879 2.19093035 2.2035219  2.21611346 2.22870501 2.24129656 2.25388812 2.26647967 2.27907122 2.29166278 2.30425433 2.31684588 2.32943744 2.34202899 2.35462055 2.3672121  2.37980365 2.39239521 2.40498676 2.41757831 2.43016987 2.44276142 2.45535298 2.46794453 2.48053608 2.49312764 2.50571919 2.51831074 2.5309023  2.54349385 2.55608541 2.56867696 2.58126851 2.59386007 2.60645162 2.61904317 2.63163473 2.64422628 2.65681784 2.66940939 2.68200094 2.6945925  2.70718405 2.7197756  2.73236716 2.74495871 2.75755027 2.77014182 2.78273337 2.79532493 2.80791648 2.82050803 2.83309959 2.84569114 2.85828269 2.87087425 2.8834658  2.89605736 2.90864891 2.92124046 2.93383202 2.94642357 2.95901512 2.97160668 2.98419823 2.99678979 3.00938134 3.02197289 3.03456445 3.047156   3.05974755 3.07233911 3.08493066 3.09752222 3.11011377 3.12270532 3.13529688 3.14788843 3.16047998 3.17307154 3.18566309 3.19825465 3.2108462  3.22343775 3.23602931 3.24862086 3.26121241 3.27380397 3.28639552 3.29898708 3.31157863 3.32417018 3.33676174 3.34935329 3.36194484 3.3745364  3.38712795 3.3997195  3.41231106 3.42490261 3.43749417 3.45008572 3.46267727 3.47526883 3.48786038 3.50045193 3.51304349 3.52563504 3.5382266 3.55081815 3.5634097  3.57600126 3.58859281 3.60118436 3.61377592 3.62636747 3.63895903 3.65155058 3.66414213 3.67673369 3.68932524 3.70191679 3.71450835 3.7270999  3.73969146 3.75228301 3.76487456 3.77746612 3.79005767 3.80264922 3.81524078 3.82783233 3.84042389 3.85301544 3.86560699 3.87819855 3.8907901  3.90338165 3.91597321 3.92856476 3.94115631 3.95374787 3.96633942 3.97893098 3.99152253 4.00411408 4.01670564 4.02929719 4.04188874 4.0544803  4.06707185 4.07966341 4.09225496 4.10484651 4.11743807 4.13002962 4.14262117 4.15521273 4.16780428 4.18039584 4.19298739 4.20557894 4.2181705 4.23076205 4.2433536  4.25594516 4.26853671 4.28112827 4.29371982 4.30631137 4.31890293 4.33149448 4.34408603 4.35667759 4.36926914 4.3818607  4.39445225 4.4070438  4.41963536 4.43222691 4.44481846 4.45741002 4.47000157 4.48259312 4.49518468 4.50777623 4.52036779 4.53295934 4.54555089 4.55814245 4.570734   4.58332555 4.59591711 4.60850866 4.62110022 4.63369177 4.64628332 4.65887488 4.67146643 4.68405798 4.69664954 4.70924109 4.72183265 4.7344242  4.74701575 4.75960731 4.77219886 4.78479041 4.79738197 4.80997352 4.82256508 4.83515663 4.84774818 4.86033974 4.87293129 4.88552284 4.8981144 4.91070595 4.92329751 4.93588906 4.94848061 4.96107217 4.97366372 4.98625527 4.99884683 5.01143838 5.02402993 5.03662149 5.04921304 5.0618046  5.07439615 5.0869877  5.09957926 5.11217081 5.12476236 5.13735392 5.14994547 5.16253703 5.17512858 5.18772013 5.20031169 5.21290324 5.22549479 5.23808635 5.2506779  5.26326946 5.27586101 5.28845256 5.30104412 5.31363567 5.32622722 5.33881878 5.35141033 5.36400189 5.37659344 5.38918499 5.40177655 5.4143681  5.42695965 5.43955121 5.45214276 5.46473432 5.47732587 5.48991742 5.50250898 5.51510053 5.52769208 5.54028364 5.55287519 5.56546675 5.5780583 5.59064985 5.60324141 5.61583296 5.62842451 5.64101607 5.65360762 5.66619917 5.67879073 5.69138228 5.70397384 5.71656539 5.72915694 5.7417485  5.75434005 5.7669316  5.77952316 5.79211471 5.80470627 5.81729782 5.82988937 5.84248093 5.85507248 5.86766403 5.88025559 5.89284714 5.9054387  5.91803025 5.9306218  5.94321336 5.95580491 5.96839646 5.98098802 5.99357957 6.00617113 6.01876268 6.03135423 6.04394579 6.05653734 6.06912889 6.08172045 6.094312   6.10690356 6.11949511 6.13208666 6.14467822 6.15726977 6.16986132 6.18245288 6.19504443 6.20763598 6.22022754 6.23281909 6.24541065 6.2580022 6.27059375 6.28318531][ 0.00000000e+00  1.25912210e-02  2.51804457e-02  3.77656782e-02  5.03449231e-02  6.29161861e-02  7.54774740e-02  8.80267954e-02  1.00562160e-01  1.13081582e-01  1.25583075e-01  1.38064657e-01  1.50524350e-01  1.62960178e-01  1.75370170e-01  1.87752357e-01  2.00104777e-01  2.12425471e-01  2.24712487e-01  2.36963875e-01  2.49177694e-01  2.61352007e-01  2.73484884e-01  2.85574401e-01  2.97618642e-01  3.09615697e-01  3.21563664e-01  3.33460648e-01  3.45304764e-01  3.57094133e-01  3.68826887e-01  3.80501166e-01  3.92115117e-01  4.03666901e-01  4.15154685e-01  4.26576649e-01  4.37930980e-01  4.49215880e-01  4.60429559e-01  4.71570240e-01  4.82636155e-01  4.93625550e-01  5.04536683e-01  5.15367825e-01  5.26117258e-01  5.36783277e-01  5.47364192e-01  5.57858325e-01  5.68264012e-01  5.78579603e-01  5.88803464e-01  5.98933973e-01  6.08969524e-01  6.18908525e-01  6.28749402e-01  6.38490593e-01  6.48130555e-01  6.57667759e-01  6.67100693e-01  6.76427862e-01  6.85647786e-01  6.94759004e-01  7.03760071e-01  7.12649561e-01  7.21426063e-01  7.30088187e-01  7.38634559e-01  7.47063824e-01  7.55374645e-01  7.63565706e-01  7.71635707e-01  7.79583369e-01  7.87407432e-01  7.95106655e-01  8.02679818e-01  8.10125720e-01  8.17443181e-01  8.24631039e-01  8.31688157e-01  8.38613415e-01  8.45405714e-01  8.52063978e-01  8.58587152e-01  8.64974201e-01  8.71224113e-01  8.77335896e-01  8.83308582e-01  8.89141224e-01  8.94832897e-01  9.00382698e-01  9.05789748e-01  9.11053189e-01  9.16172188e-01  9.21145931e-01  9.25973632e-01  9.30654524e-01  9.35187865e-01  9.39572937e-01  9.43809043e-01  9.47895514e-01  9.51831701e-01  9.55616979e-01  9.59250748e-01  9.62732434e-01  9.66061482e-01  9.69237367e-01  9.72259583e-01  9.75127652e-01  9.77841120e-01  9.80399556e-01  9.82802554e-01  9.85049734e-01  9.87140738e-01  9.89075237e-01  9.90852922e-01  9.92473513e-01  9.93936751e-01  9.95242406e-01  9.96390270e-01  9.97380161e-01  9.98211922e-01  9.98885422e-01  9.99400553e-01  9.99757234e-01  9.99955409e-01  9.99995045e-01  9.99876138e-01  9.99598704e-01  9.99162789e-01  9.98568462e-01  9.97815817e-01  9.96904972e-01  9.95836074e-01  9.94609290e-01  9.93224816e-01  9.91682871e-01  9.89983699e-01  9.88127571e-01  9.86114779e-01  9.83945644e-01  9.81620509e-01  9.79139743e-01  9.76503739e-01  9.73712915e-01  9.70767714e-01  9.67668602e-01  9.64416071e-01  9.61010637e-01  9.57452839e-01  9.53743241e-01  9.49882432e-01  9.45871024e-01  9.41709653e-01  9.37398978e-01  9.32939684e-01  9.28332476e-01  9.23578085e-01  9.18677266e-01  9.13630795e-01  9.08439472e-01  9.03104121e-01  8.97625587e-01  8.92004738e-01  8.86242467e-01  8.80339686e-01  8.74297332e-01  8.68116362e-01  8.61797756e-01  8.55342517e-01  8.48751667e-01  8.42026252e-01  8.35167337e-01  8.28176011e-01  8.21053382e-01  8.13800579e-01  8.06418751e-01  7.98909070e-01  7.91272725e-01  7.83510928e-01  7.75624910e-01  7.67615920e-01  7.59485227e-01  7.51234123e-01  7.42863914e-01  7.34375927e-01  7.25771508e-01  7.17052023e-01  7.08218851e-01  6.99273396e-01  6.90217074e-01  6.81051321e-01  6.71777591e-01  6.62397354e-01  6.52912097e-01  6.43323324e-01  6.33632555e-01  6.23841327e-01  6.13951192e-01  6.03963718e-01  5.93880488e-01  5.83703102e-01  5.73433172e-01  5.63072327e-01  5.52622210e-01  5.42084477e-01  5.31460800e-01  5.20752862e-01  5.09962361e-01  4.99091008e-01  4.88140526e-01  4.77112653e-01  4.66009135e-01  4.54831734e-01  4.43582221e-01  4.32262381e-01  4.20874008e-01  4.09418907e-01  3.97898895e-01  3.86315798e-01  3.74671452e-01  3.62967704e-01  3.51206409e-01  3.39389432e-01  3.27518647e-01  3.15595935e-01  3.03623187e-01  2.91602301e-01  2.79535183e-01  2.67423746e-01  2.55269910e-01  2.43075602e-01  2.30842756e-01  2.18573311e-01  2.06269212e-01  1.93932410e-01  1.81564862e-01  1.69168526e-01  1.56745371e-01  1.44297363e-01  1.31826479e-01  1.19334693e-01  1.06823988e-01  9.42963467e-02  8.17537549e-02  6.91982015e-02  5.66316770e-02  4.40561738e-02  3.14736857e-02  1.88862077e-02  6.29573527e-03 -6.29573527e-03 -1.88862077e-02 -3.14736857e-02 -4.40561738e-02 -5.66316770e-02 -6.91982015e-02 -8.17537549e-02 -9.42963467e-02 -1.06823988e-01 -1.19334693e-01 -1.31826479e-01 -1.44297363e-01 -1.56745371e-01 -1.69168526e-01 -1.81564862e-01 -1.93932410e-01 -2.06269212e-01 -2.18573311e-01 -2.30842756e-01 -2.43075602e-01 -2.55269910e-01 -2.67423746e-01 -2.79535183e-01 -2.91602301e-01 -3.03623187e-01 -3.15595935e-01 -3.27518647e-01 -3.39389432e-01 -3.51206409e-01 -3.62967704e-01 -3.74671452e-01 -3.86315798e-01 -3.97898895e-01 -4.09418907e-01 -4.20874008e-01 -4.32262381e-01 -4.43582221e-01 -4.54831734e-01 -4.66009135e-01 -4.77112653e-01 -4.88140526e-01 -4.99091008e-01 -5.09962361e-01 -5.20752862e-01 -5.31460800e-01 -5.42084477e-01 -5.52622210e-01 -5.63072327e-01 -5.73433172e-01 -5.83703102e-01 -5.93880488e-01 -6.03963718e-01 -6.13951192e-01 -6.23841327e-01 -6.33632555e-01 -6.43323324e-01 -6.52912097e-01 -6.62397354e-01 -6.71777591e-01 -6.81051321e-01 -6.90217074e-01 -6.99273396e-01 -7.08218851e-01 -7.17052023e-01 -7.25771508e-01 -7.34375927e-01 -7.42863914e-01 -7.51234123e-01 -7.59485227e-01 -7.67615920e-01 -7.75624910e-01 -7.83510928e-01 -7.91272725e-01 -7.98909070e-01 -8.06418751e-01 -8.13800579e-01 -8.21053382e-01 -8.28176011e-01 -8.35167337e-01 -8.42026252e-01 -8.48751667e-01 -8.55342517e-01 -8.61797756e-01 -8.68116362e-01 -8.74297332e-01 -8.80339686e-01 -8.86242467e-01 -8.92004738e-01 -8.97625587e-01 -9.03104121e-01 -9.08439472e-01 -9.13630795e-01 -9.18677266e-01 -9.23578085e-01 -9.28332476e-01 -9.32939684e-01 -9.37398978e-01 -9.41709653e-01 -9.45871024e-01 -9.49882432e-01 -9.53743241e-01 -9.57452839e-01 -9.61010637e-01 -9.64416071e-01 -9.67668602e-01 -9.70767714e-01 -9.73712915e-01 -9.76503739e-01 -9.79139743e-01 -9.81620509e-01 -9.83945644e-01 -9.86114779e-01 -9.88127571e-01 -9.89983699e-01 -9.91682871e-01 -9.93224816e-01 -9.94609290e-01 -9.95836074e-01 -9.96904972e-01 -9.97815817e-01 -9.98568462e-01 -9.99162789e-01 -9.99598704e-01 -9.99876138e-01 -9.99995045e-01 -9.99955409e-01 -9.99757234e-01 -9.99400553e-01 -9.98885422e-01 -9.98211922e-01 -9.97380161e-01 -9.96390270e-01 -9.95242406e-01 -9.93936751e-01 -9.92473513e-01 -9.90852922e-01 -9.89075237e-01 -9.87140738e-01 -9.85049734e-01 -9.82802554e-01 -9.80399556e-01 -9.77841120e-01 -9.75127652e-01 -9.72259583e-01 -9.69237367e-01 -9.66061482e-01 -9.62732434e-01 -9.59250748e-01 -9.55616979e-01 -9.51831701e-01 -9.47895514e-01 -9.43809043e-01 -9.39572937e-01 -9.35187865e-01 -9.30654524e-01 -9.25973632e-01 -9.21145931e-01 -9.16172188e-01 -9.11053189e-01 -9.05789748e-01 -9.00382698e-01 -8.94832897e-01 -8.89141224e-01 -8.83308582e-01 -8.77335896e-01 -8.71224113e-01 -8.64974201e-01 -8.58587152e-01 -8.52063978e-01 -8.45405714e-01 -8.38613415e-01 -8.31688157e-01 -8.24631039e-01 -8.17443181e-01 -8.10125720e-01 -8.02679818e-01 -7.95106655e-01 -7.87407432e-01 -7.79583369e-01 -7.71635707e-01 -7.63565706e-01 -7.55374645e-01 -7.47063824e-01 -7.38634559e-01 -7.30088187e-01 -7.21426063e-01 -7.12649561e-01 -7.03760071e-01 -6.94759004e-01 -6.85647786e-01 -6.76427862e-01 -6.67100693e-01 -6.57667759e-01 -6.48130555e-01 -6.38490593e-01 -6.28749402e-01 -6.18908525e-01 -6.08969524e-01 -5.98933973e-01 -5.88803464e-01 -5.78579603e-01 -5.68264012e-01 -5.57858325e-01 -5.47364192e-01 -5.36783277e-01 -5.26117258e-01 -5.15367825e-01 -5.04536683e-01 -4.93625550e-01 -4.82636155e-01 -4.71570240e-01 -4.60429559e-01 -4.49215880e-01 -4.37930980e-01 -4.26576649e-01 -4.15154685e-01 -4.03666901e-01 -3.92115117e-01 -3.80501166e-01 -3.68826887e-01 -3.57094133e-01 -3.45304764e-01 -3.33460648e-01 -3.21563664e-01 -3.09615697e-01 -2.97618642e-01 -2.85574401e-01 -2.73484884e-01 -2.61352007e-01 -2.49177694e-01 -2.36963875e-01 -2.24712487e-01 -2.12425471e-01 -2.00104777e-01 -1.87752357e-01 -1.75370170e-01 -1.62960178e-01 -1.50524350e-01 -1.38064657e-01 -1.25583075e-01 -1.13081582e-01 -1.00562160e-01 -8.80267954e-02 -7.54774740e-02 -6.29161861e-02 -5.03449231e-02 -3.77656782e-02 -2.51804457e-02 -1.25912210e-02 -2.44929360e-16]<class 'numpy.ndarray'>

import matplotlib.pyplot as pltimport numpy as npX=np.linspace(-np.pi,np.pi,256,endpoint=True)C,S=np.cos(X),np.sin(X)plt.plot(X,C)plt.plot(X,S)plt.show()

y=ax^2+bx+c (一元二次方程)

import numpy as npimport matplotlib.pyplot as pltA=1B=2C=4A1=-2B1=-2C1=24X=np.linspace(-10,10,500,endpoint=True)Y=A*(X*X)+B*X+CY1=A1*(X*X)+B1*X+C1plt.plot(X,Y)plt.plot(X,Y1)plt.show()

y=x^2+2x+4

y1=-2x^2-2x+24

标签: #python画图函数 #python图形编程基础 #python画图基础教程 #python2764