现在我们添加图后,没有指定x轴代表什么,y轴代表什么,以及这个图的标题是什么。因此以下我们通过一些属性来设置一下。
设置线条样式:
- 使用plot方法:plot方法就是用来绘制线条的,因此可以在绘制的时候就把线条相关的样式通过参数传进去。示例代码如下:
plt.plot(x,y,linewidth=2)
- 通过Line2D对象来设置:plot方法会返回一个装有Line2D对象的列表,比如lines=plt.plot(x1,y1,x2,y2)因为绘制了两根线条,因此lines中会有两个2D对象。而如果plot只绘制一根线条,那么lines中就只有一Line2D对象。拿到这个Line2D对象后就可以通过set_属性名设置线条的样式了:
lines = plt.plot(x,y) line = lines[0] line.set_aa(False) #关掉反锯齿 line.set_alpha(0.5) #设置0.5的透明度
- 使用plt.setp来设置:示例代码如下:
lines = plt.plot(x,y) plt.setp(lines,linewidth=10,alpha=0.5)
-
更多Line2D属性:
设置轴和标题:
- 设置轴名称:可以通过
plt.xlabel
和plt.ylabel
来设置x
轴和y
轴的的名称。示例代码如下:
plt.plot(x,y,linewidth=10,color='red') plt.xlabel("x轴") plt.ylabel("y轴")
默认情况下是显示不了中文的。需要设置字体。可以通过以下代码来实现:
https://dribbble.com/alashan/collections/4637316,https://dribbble.com/qing857/collections/4639912
https://dribbble.com/alashan/collections/4637315,https://dribbble.com/qing857/collections/4639911
https://dribbble.com/alashan/collections/4637314,https://dribbble.com/qing857/collections/4639909
https://dribbble.com/alashan/collections/4637313,https://dribbble.com/qing857/collections/4639908
https://dribbble.com/alashan/collections/4637312,https://dribbble.com/qing857/collections/4639907
https://dribbble.com/alashan/collections/4637311,https://dribbble.com/qing857/collections/4639906
https://dribbble.com/alashan/collections/4637310,https://dribbble.com/qing857/collections/4639905
https://dribbble.com/alashan/collections/4637309,https://dribbble.com/qing857/collections/4639904
https://dribbble.com/alashan/collections/4637308,https://dribbble.com/qing857/collections/4639903
https://dribbble.com/alashan/collections/4637307,https://dribbble.com/qing857/collections/4639902
https://dribbble.com/alashan/collections/4637306,https://dribbble.com/qing857/collections/4639901
https://dribbble.com/alashan/collections/4637305,https://dribbble.com/qing857/collections/4639900
https://dribbble.com/alashan/collections/4637304,https://dribbble.com/qing857/collections/4639898
https://dribbble.com/alashan/collections/4637303,https://dribbble.com/qing857/collections/4639897
https://dribbble.com/alashan/collections/4637301,https://dribbble.com/qing857/collections/4639896
https://dribbble.com/alashan/collections/4637299,https://dribbble.com/qing857/collections/4639893
https://dribbble.com/alashan/collections/4637298,https://dribbble.com/qing857/collections/4639892
https://dribbble.com/alashan/collections/4637297,https://dribbble.com/qing857/collections/4639890
https://dribbble.com/anshanb/collections/4637345,https://dribbble.com/yang968/collections/4639942
https://dribbble.com/anshanb/collections/4637344,https://dribbble.com/yang968/collections/4639941
https://dribbble.com/anshanb/collections/4637343,https://dribbble.com/yang968/collections/4639939
https://dribbble.com/anshanb/collections/4637342,https://dribbble.com/yang968/collections/4639938
https://dribbble.com/anshanb/collections/4637339,https://dribbble.com/yang968/collections/4639937
https://dribbble.com/anshanb/collections/4637338,https://dribbble.com/yang968/collections/4639935
https://dribbble.com/anshanb/collections/4637337,https://dribbble.com/yang968/collections/4639934
https://dribbble.com/anshanb/collections/4637336,https://dribbble.com/yang968/collections/4639932
https://dribbble.com/anshanb/collections/4637335,https://dribbble.com/yang968/collections/4639931
https://dribbble.com/anshanb/collections/4637334,https://dribbble.com/yang968/collections/4639928
https://dribbble.com/anshanb/collections/4637333,https://dribbble.com/yang968/collections/4639927
https://dribbble.com/anshanb/collections/4637332,https://dribbble.com/yang968/collections/4639926
https://dribbble.com/anshanb/collections/4637331,https://dribbble.com/yang968/collections/4639925
https://dribbble.com/anshanb/collections/4637329,https://dribbble.com/yang968/collections/4639924
https://dribbble.com/anshanb/collections/4637327,https://dribbble.com/yang968/collections/4639923
https://dribbble.com/anshanb/collections/4637325,https://dribbble.com/yang968/collections/4639922
https://dribbble.com/anshanb/collections/4637323,https://dribbble.com/yang968/collections/4639918
https://dribbble.com/anshanb/collections/4637322,https://dribbble.com/yang968/collections/4639917
https://dribbble.com/anqingb/collections/4637371,https://dribbble.com/ablo351/collections/4639968
https://dribbble.com/anqingb/collections/4637370,https://dribbble.com/ablo351/collections/4639966
https://dribbble.com/anqingb/collections/4637368,https://dribbble.com/ablo351/collections/4639964
https://dribbble.com/anqingb/collections/4637367,https://dribbble.com/ablo351/collections/4639963
https://dribbble.com/anqingb/collections/4637366,https://dribbble.com/ablo351/collections/4639962
https://dribbble.com/anqingb/collections/4637365,https://dribbble.com/ablo351/collections/4639961
https://dribbble.com/anqingb/collections/4637364,https://dribbble.com/ablo351/collections/4639960
https://dribbble.com/anqingb/collections/4637363,https://dribbble.com/ablo351/collections/4639959
https://dribbble.com/anqingb/collections/4637362,https://dribbble.com/ablo351/collections/4639958
https://dribbble.com/anqingb/collections/4637361,https://dribbble.com/ablo351/collections/4639957
https://dribbble.com/anqingb/collections/4637360,https://dribbble.com/ablo351/collections/4639956
https://dribbble.com/anqingb/collections/4637359,https://dribbble.com/ablo351/collections/4639955
https://dribbble.com/anqingb/collections/4637358,https://dribbble.com/ablo351/collections/4639953
https://dribbble.com/anqingb/collections/4637357,https://dribbble.com/ablo351/collections/4639952
https://dribbble.com/anqingb/collections/4637356,https://dribbble.com/ablo351/collections/4639951
https://dribbble.com/anqingb/collections/4637355,https://dribbble.com/ablo351/collections/4639950
https://dribbble.com/anqingb/collections/4637354,https://dribbble.com/ablo351/collections/4639946
https://dribbble.com/anqingb/collections/4637353,https://dribbble.com/ablo351/collections/4639945
https://dribbble.com/anyangb/collections/4637391,https://dribbble.com/shun258/collections/4639992
https://dribbble.com/anyangb/collections/4637390,https://dribbble.com/shun258/collections/4639991
https://dribbble.com/anyangb/collections/4637389,https://dribbble.com/shun258/collections/4639990
https://dribbble.com/anyangb/collections/4637388,https://dribbble.com/shun258/collections/4639989
https://dribbble.com/anyangb/collections/4637387,https://dribbble.com/shun258/collections/4639988
https://dribbble.com/anyangb/collections/4637386,https://dribbble.com/shun258/collections/4639985
https://dribbble.com/anyangb/collections/4637385,https://dribbble.com/shun258/collections/4639984
https://dribbble.com/anyangb/collections/4637384,https://dribbble.com/shun258/collections/4639983
https://dribbble.com/anyangb/collections/4637383,https://dribbble.com/shun258/collections/4639981
https://dribbble.com/anyangb/collections/4637382,https://dribbble.com/shun258/collections/4639980
https://dribbble.com/anyangb/collections/4637381,https://dribbble.com/shun258/collections/4639979
https://dribbble.com/anyangb/collections/4637380,https://dribbble.com/shun258/collections/4639978
https://dribbble.com/anyangb/collections/4637379,https://dribbble.com/shun258/collections/4639977
https://dribbble.com/anyangb/collections/4637378,https://dribbble.com/shun258/collections/4639975
https://dribbble.com/anyangb/collections/4637377,https://dribbble.com/shun258/collections/4639974
https://dribbble.com/anyangb/collections/4637376,https://dribbble.com/shun258/collections/4639973
https://dribbble.com/anyangb/collections/4637374,https://dribbble.com/shun258/collections/4639972
https://dribbble.com/anyangb/collections/4637373,https://dribbble.com/shun258/collections/4639971
https://dribbble.com/abablog/collections/4637410,https://dribbble.com/iblo306/collections/4640014
https://dribbble.com/abablog/collections/4637409,https://dribbble.com/iblo306/collections/4640013
https://dribbble.com/abablog/collections/4637408,https://dribbble.com/iblo306/collections/4640011
https://dribbble.com/abablog/collections/4637407,https://dribbble.com/iblo306/collections/4640010
https://dribbble.com/abablog/collections/4637406,https://dribbble.com/iblo306/collections/4640009
https://dribbble.com/abablog/collections/4637405,https://dribbble.com/iblo306/collections/4640008
https://dribbble.com/abablog/collections/4637404,https://dribbble.com/iblo306/collections/4640006
https://dribbble.com/abablog/collections/4637403,https://dribbble.com/iblo306/collections/4640005
https://dribbble.com/abablog/collections/4637402,https://dribbble.com/iblo306/collections/4640004
https://dribbble.com/abablog/collections/4637401,https://dribbble.com/iblo306/collections/4640003
https://dribbble.com/abablog/collections/4637400,https://dribbble.com/iblo306/collections/4640001
https://dribbble.com/abablog/collections/4637399,https://dribbble.com/iblo306/collections/4640000
https://dribbble.com/abablog/collections/4637398,https://dribbble.com/iblo306/collections/4639999
https://dribbble.com/abablog/collections/4637397,https://dribbble.com/iblo306/collections/4639998
https://dribbble.com/abablog/collections/4637396,https://dribbble.com/iblo306/collections/4639997
https://dribbble.com/abablog/collections/4637395,https://dribbble.com/iblo306/collections/4639996
https://dribbble.com/abablog/collections/4637394,https://dribbble.com/iblo306/collections/4639994
https://dribbble.com/abablog/collections/4637393,https://dribbble.com/iblo306/collections/4639993
https://dribbble.com/anshunb/collections/4637437,https://dribbble.com/kang593/collections/4640040
https://dribbble.com/anshunb/collections/4637435,https://dribbble.com/kang593/collections/4640036
https://dribbble.com/anshunb/collections/4637434,https://dribbble.com/kang593/collections/4640035
https://dribbble.com/anshunb/collections/4637433,https://dribbble.com/kang593/collections/4640034
https://dribbble.com/anshunb/collections/4637431,https://dribbble.com/kang593/collections/4640032
https://dribbble.com/anshunb/collections/4637428,https://dribbble.com/kang593/collections/4640031
https://dribbble.com/anshunb/collections/4637427,https://dribbble.com/kang593/collections/4640030
https://dribbble.com/anshunb/collections/4637426,https://dribbble.com/kang593/collections/4640029
https://dribbble.com/anshunb/collections/4637425,https://dribbble.com/kang593/collections/4640028
https://dribbble.com/anshunb/collections/4637424,https://dribbble.com/kang593/collections/4640026
https://dribbble.com/anshunb/collections/4637423,https://dribbble.com/kang593/collections/4640025
https://dribbble.com/anshunb/collections/4637421,https://dribbble.com/kang593/collections/4640024
https://dribbble.com/anshunb/collections/4637420,https://dribbble.com/kang593/collections/4640022
https://dribbble.com/anshunb/collections/4637418,https://dribbble.com/kang593/collections/4640021
https://dribbble.com/anshunb/collections/4637417,https://dribbble.com/kang593/collections/4640020
https://dribbble.com/anshunb/collections/4637416,https://dribbble.com/kang593/collections/4640019
https://dribbble.com/anshunb/collections/4637415,https://dribbble.com/kang593/collections/4640018
https://dribbble.com/anshunb/collections/4637414,https://dribbble.com/kang593/collections/4640017
https://dribbble.com/aliblog/collections/4637458,https://dribbble.com/esub600/collections/4640066
https://dribbble.com/aliblog/collections/4637457,https://dribbble.com/esub600/collections/4640065
https://dribbble.com/aliblog/collections/4637456,https://dribbble.com/esub600/collections/4640064
https://dribbble.com/aliblog/collections/4637455,https://dribbble.com/esub600/collections/4640063
https://dribbble.com/aliblog/collections/4637454,https://dribbble.com/esub600/collections/4640062
https://dribbble.com/aliblog/collections/4637453,https://dribbble.com/esub600/collections/4640061
https://dribbble.com/aliblog/collections/4637452,https://dribbble.com/esub600/collections/4640060
https://dribbble.com/aliblog/collections/4637451,https://dribbble.com/esub600/collections/4640058
https://dribbble.com/aliblog/collections/4637450,https://dribbble.com/esub600/collections/4640057
https://dribbble.com/aliblog/collections/4637449,https://dribbble.com/esub600/collections/4640055
https://dribbble.com/aliblog/collections/4637448,https://dribbble.com/esub600/collections/4640053
https://dribbble.com/aliblog/collections/4637447,https://dribbble.com/esub600/collections/4640052
https://dribbble.com/aliblog/collections/4637446,https://dribbble.com/esub600/collections/4640051
https://dribbble.com/aliblog/collections/4637445,https://dribbble.com/esub600/collections/4640050
https://dribbble.com/aliblog/collections/4637444,https://dribbble.com/esub600/collections/4640049
https://dribbble.com/aliblog/collections/4637443,https://dribbble.com/esub600/collections/4640047
https://dribbble.com/aliblog/collections/4637442,https://dribbble.com/esub600/collections/4640046
https://dribbble.com/aliblog/collections/4637441,https://dribbble.com/esub600/collections/4640043
https://dribbble.com/ankangb/collections/4637484,https://dribbble.com/etai427/collections/4640099
https://dribbble.com/ankangb/collections/4637483,https://dribbble.com/etai427/collections/4640097
https://dribbble.com/ankangb/collections/4637482,https://dribbble.com/etai427/collections/4640096
https://dribbble.com/ankangb/collections/4637481,https://dribbble.com/etai427/collections/4640094
https://dribbble.com/ankangb/collections/4637480,https://dribbble.com/etai427/collections/4640092
https://dribbble.com/ankangb/collections/4637479,https://dribbble.com/etai427/collections/4640091
https://dribbble.com/ankangb/collections/4637478,https://dribbble.com/etai427/collections/4640089
https://dribbble.com/ankangb/collections/4637475,https://dribbble.com/etai427/collections/4640088
https://dribbble.com/ankangb/collections/4637474,https://dribbble.com/etai427/collections/4640086
https://dribbble.com/ankangb/collections/4637471,https://dribbble.com/etai427/collections/4640085
https://dribbble.com/ankangb/collections/4637469,https://dribbble.com/etai427/collections/4640084
https://dribbble.com/ankangb/collections/4637468,https://dribbble.com/etai427/collections/4640081
https://dribbble.com/ankangb/collections/4637467,https://dribbble.com/etai427/collections/4640079
https://dribbble.com/ankangb/collections/4637466,https://dribbble.com/etai427/collections/4640078
https://dribbble.com/ankangb/collections/4637465,https://dribbble.com/etai427/collections/4640077
https://dribbble.com/ankangb/collections/4637464,https://dribbble.com/etai427/collections/4640074
https://dribbble.com/ankangb/collections/4637463,https://dribbble.com/etai427/collections/4640072
https://dribbble.com/ankangb/collections/4637461,https://dribbble.com/etai427/collections/4640071
https://dribbble.com/akesubl/collections/4637510,https://dribbble.com/ijin181/collections/4640125
https://dribbble.com/akesubl/collections/4637508,https://dribbble.com/ijin181/collections/4640124
https://dribbble.com/akesubl/collections/4637507,https://dribbble.com/ijin181/collections/4640122
https://dribbble.com/akesubl/collections/4637506,https://dribbble.com/ijin181/collections/4640120
https://dribbble.com/akesubl/collections/4637504,https://dribbble.com/ijin181/collections/4640117
https://dribbble.com/akesubl/collections/4637503,https://dribbble.com/ijin181/collections/4640116
https://dribbble.com/akesubl/collections/4637502,https://dribbble.com/ijin181/collections/4640114
https://dribbble.com/akesubl/collections/4637501,https://dribbble.com/ijin181/collections/4640111
https://dribbble.com/akesubl/collections/4637499,https://dribbble.com/ijin181/collections/4640110
https://dribbble.com/akesubl/collections/4637498,https://dribbble.com/ijin181/collections/4640109
https://dribbble.com/akesubl/collections/4637497,https://dribbble.com/ijin181/collections/4640108
https://dribbble.com/akesubl/collections/4637495,https://dribbble.com/ijin181/collections/4640107
https://dribbble.com/akesubl/collections/4637493,https://dribbble.com/ijin181/collections/4640106
https://dribbble.com/akesubl/collections/4637492,https://dribbble.com/ijin181/collections/4640105
https://dribbble.com/akesubl/collections/4637491,https://dribbble.com/ijin181/collections/4640104
https://dribbble.com/akesubl/collections/4637490,https://dribbble.com/ijin181/collections/4640102
https://dribbble.com/akesubl/collections/4637488,https://dribbble.com/ijin181/collections/4640101
https://dribbble.com/akesubl/collections/4637487,https://dribbble.com/ijin181/collections/4640100
https://dribbble.com/aletaib/collections/4637530,https://dribbble.com/odin307/collections/4640150
https://dribbble.com/aletaib/collections/4637529,https://dribbble.com/odin307/collections/4640148
https://dribbble.com/aletaib/collections/4637528,https://dribbble.com/odin307/collections/4640147
https://dribbble.com/aletaib/collections/4637527,https://dribbble.com/odin307/collections/4640146
https://dribbble.com/aletaib/collections/4637526,https://dribbble.com/odin307/collections/4640145
https://dribbble.com/aletaib/collections/4637525,https://dribbble.com/odin307/collections/4640143
https://dribbble.com/aletaib/collections/4637524,https://dribbble.com/odin307/collections/4640142
https://dribbble.com/aletaib/collections/4637523,https://dribbble.com/odin307/collections/4640141
https://dribbble.com/aletaib/collections/4637522,https://dribbble.com/odin307/collections/4640140
https://dribbble.com/aletaib/collections/4637521,https://dribbble.com/odin307/collections/4640138
https://dribbble.com/aletaib/collections/4637519,https://dribbble.com/odin307/collections/4640137
https://dribbble.com/aletaib/collections/4637518,https://dribbble.com/odin307/collections/4640136
https://dribbble.com/aletaib/collections/4637517,https://dribbble.com/odin307/collections/4640135
https://dribbble.com/aletaib/collections/4637516,https://dribbble.com/odin307/collections/4640134
https://dribbble.com/aletaib/collections/4637514,https://dribbble.com/odin307/collections/4640133
https://dribbble.com/aletaib/collections/4637513,https://dribbble.com/odin307/collections/4640131
https://dribbble.com/aletaib/collections/4637512,https://dribbble.com/odin307/collections/4640130
https://dribbble.com/aletaib/collections/4637511,https://dribbble.com/odin307/collections/4640129
https://dribbble.com/beiaili/collections/4637551,https://dribbble.com/otou938/collections/4640178
https://dribbble.com/beiaili/collections/4637550,https://dribbble.com/otou938/collections/4640177
https://dribbble.com/beiaili/collections/4637548,https://dribbble.com/otou938/collections/4640176
https://dribbble.com/beiaili/collections/4637547,https://dribbble.com/otou938/collections/4640174
https://dribbble.com/beiaili/collections/4637546,https://dribbble.com/otou938/collections/4640173
https://dribbble.com/beiaili/collections/4637545,https://dribbble.com/otou938/collections/4640172
https://dribbble.com/beiaili/collections/4637544,https://dribbble.com/otou938/collections/4640169
https://dribbble.com/beiaili/collections/4637543,https://dribbble.com/otou938/collections/4640168
https://dribbble.com/beiaili/collections/4637542,https://dribbble.com/otou938/collections/4640166
https://dribbble.com/beiaili/collections/4637541,https://dribbble.com/otou938/collections/4640164
https://dribbble.com/beiaili/collections/4637539,https://dribbble.com/otou938/collections/4640163
https://dribbble.com/beiaili/collections/4637538,https://dribbble.com/otou938/collections/4640162
https://dribbble.com/beiaili/collections/4637537,https://dribbble.com/otou938/collections/4640161
https://dribbble.com/beiaili/collections/4637536,https://dribbble.com/otou938/collections/4640160
https://dribbble.com/beiaili/collections/4637535,https://dribbble.com/otou938/collections/4640159
https://dribbble.com/beiaili/collections/4637534,https://dribbble.com/otou938/collections/4640157
https://dribbble.com/beiaili/collections/4637533,https://dribbble.com/otou938/collections/4640155
https://dribbble.com/beiaili/collections/4637532,https://dribbble.com/otou938/collections/4640154
https://dribbble.com/baodyiz/collections/4637571,https://dribbble.com/yann176/collections/4640202
https://dribbble.com/baodyiz/collections/4637570,https://dribbble.com/yann176/collections/4640201
https://dribbble.com/baodyiz/collections/4637569,https://dribbble.com/yann176/collections/4640199
https://dribbble.com/baodyiz/collections/4637568,https://dribbble.com/yann176/collections/4640197
https://dribbble.com/baodyiz/collections/4637567,https://dribbble.com/yann176/collections/4640196
https://dribbble.com/baodyiz/collections/4637566,https://dribbble.com/yann176/collections/4640195
https://dribbble.com/baodyiz/collections/4637565,https://dribbble.com/yann176/collections/4640194
https://dribbble.com/baodyiz/collections/4637563,https://dribbble.com/yann176/collections/4640193
https://dribbble.com/baodyiz/collections/4637562,https://dribbble.com/yann176/collections/4640192
https://dribbble.com/baodyiz/collections/4637561,https://dribbble.com/yann176/collections/4640191
https://dribbble.com/baodyiz/collections/4637560,https://dribbble.com/yann176/collections/4640190
https://dribbble.com/baodyiz/collections/4637559,https://dribbble.com/yann176/collections/4640189
https://dribbble.com/baodyiz/collections/4637558,https://dribbble.com/yann176/collections/4640188
https://dribbble.com/baodyiz/collections/4637557,https://dribbble.com/yann176/collections/4640186
https://dribbble.com/baodyiz/collections/4637556,https://dribbble.com/yann176/collections/4640185
https://dribbble.com/baodyiz/collections/4637555,https://dribbble.com/yann176/collections/4640184
https://dribbble.com/baodyiz/collections/4637554,https://dribbble.com/yann176/collections/4640182
https://dribbble.com/baodyiz/collections/4637553,https://dribbble.com/yann176/collections/4640181
https://dribbble.com/baotoub/collections/4637595,https://dribbble.com/nxib740/collections/4640225
https://dribbble.com/baotoub/collections/4637594,https://dribbble.com/nxib740/collections/4640224
https://dribbble.com/baotoub/collections/4637593,https://dribbble.com/nxib740/collections/4640223
https://dribbble.com/baotoub/collections/4637592,https://dribbble.com/nxib740/collections/4640220
https://dribbble.com/baotoub/collections/4637591,https://dribbble.com/nxib740/collections/4640219
https://dribbble.com/baotoub/collections/4637589,https://dribbble.com/nxib740/collections/4640218
https://dribbble.com/baotoub/collections/4637588,https://dribbble.com/nxib740/collections/4640216
https://dribbble.com/baotoub/collections/4637587,https://dribbble.com/nxib740/collections/4640215
https://dribbble.com/baotoub/collections/4637586,https://dribbble.com/nxib740/collections/4640214
https://dribbble.com/baotoub/collections/4637584,https://dribbble.com/nxib740/collections/4640213
https://dribbble.com/baotoub/collections/4637583,https://dribbble.com/nxib740/collections/4640212
https://dribbble.com/baotoub/collections/4637578,https://dribbble.com/nxib740/collections/4640211
https://dribbble.com/baotoub/collections/4637577,https://dribbble.com/nxib740/collections/4640208
https://dribbble.com/baotoub/collections/4637576,https://dribbble.com/nxib740/collections/4640207
https://dribbble.com/baotoub/collections/4637575,https://dribbble.com/nxib740/collections/4640206
https://dribbble.com/baotoub/collections/4637574,https://dribbble.com/nxib740/collections/4640205
https://dribbble.com/baotoub/collections/4637573,https://dribbble.com/nxib740/collections/4640204
https://dribbble.com/baotoub/collections/4637572,https://dribbble.com/nxib740/collections/4640203
https://dribbble.com/bayanna/collections/4637616,https://dribbble.com/isha281/collections/4640252
https://dribbble.com/bayanna/collections/4637615,https://dribbble.com/isha281/collections/4640251
https://dribbble.com/bayanna/collections/4637614,https://dribbble.com/isha281/collections/4640250
https://dribbble.com/bayanna/collections/4637613,https://dribbble.com/isha281/collections/4640248
https://dribbble.com/bayanna/collections/4637612,https://dribbble.com/isha281/collections/4640246
https://dribbble.com/bayanna/collections/4637611,https://dribbble.com/isha281/collections/4640244
https://dribbble.com/bayanna/collections/4637610,https://dribbble.com/isha281/collections/4640241
https://dribbble.com/bayanna/collections/4637609,https://dribbble.com/isha281/collections/4640240
https://dribbble.com/bayanna/collections/4637608,https://dribbble.com/isha281/collections/4640239
https://dribbble.com/bayanna/collections/4637607,https://dribbble.com/isha281/collections/4640238
https://dribbble.com/bayanna/collections/4637606,https://dribbble.com/isha281/collections/4640236
https://dribbble.com/bayanna/collections/4637604,https://dribbble.com/isha281/collections/4640235
https://dribbble.com/bayanna/collections/4637603,https://dribbble.com/isha281/collections/4640234
https://dribbble.com/bayanna/collections/4637602,https://dribbble.com/isha281/collections/4640233
https://dribbble.com/bayanna/collections/4637601,https://dribbble.com/isha281/collections/4640231
https://dribbble.com/bayanna/collections/4637599,https://dribbble.com/isha281/collections/4640230
https://dribbble.com/bayanna/collections/4637598,https://dribbble.com/isha281/collections/4640229
https://dribbble.com/bayanna/collections/4637597,https://dribbble.com/isha281/collections/4640228
https://dribbble.com/benxibl/collections/4637637,https://dribbble.com/iche849/collections/4640276
https://dribbble.com/benxibl/collections/4637635,https://dribbble.com/iche849/collections/4640275
https://dribbble.com/benxibl/collections/4637634,https://dribbble.com/iche849/collections/4640274
https://dribbble.com/benxibl/collections/4637633,https://dribbble.com/iche849/collections/4640272
https://dribbble.com/benxibl/collections/4637632,https://dribbble.com/iche849/collections/4640269
https://dribbble.com/benxibl/collections/4637631,https://dribbble.com/iche849/collections/4640268
https://dribbble.com/benxibl/collections/4637629,https://dribbble.com/iche849/collections/4640267
https://dribbble.com/benxibl/collections/4637628,https://dribbble.com/iche849/collections/4640266
https://dribbble.com/benxibl/collections/4637627,https://dribbble.com/iche849/collections/4640264
https://dribbble.com/benxibl/collections/4637626,https://dribbble.com/iche849/collections/4640263
https://dribbble.com/benxibl/collections/4637625,https://dribbble.com/iche849/collections/4640262
https://dribbble.com/benxibl/collections/4637624,https://dribbble.com/iche849/collections/4640260
https://dribbble.com/benxibl/collections/4637623,https://dribbble.com/iche849/collections/4640259
https://dribbble.com/benxibl/collections/4637622,https://dribbble.com/iche849/collections/4640258
https://dribbble.com/benxibl/collections/4637621,https://dribbble.com/iche849/collections/4640257
https://dribbble.com/benxibl/collections/4637620,https://dribbble.com/iche849/collections/4640256
https://dribbble.com/benxibl/collections/4637618,https://dribbble.com/iche849/collections/4640255
https://dribbble.com/benxibl/collections/4637617,https://dribbble.com/iche849/collections/4640254
https://dribbble.com/asha926/collections/4637658,https://dribbble.com/ngbu931/collections/4640297
https://dribbble.com/asha926/collections/4637657,https://dribbble.com/ngbu931/collections/4640296
https://dribbble.com/asha926/collections/4637656,https://dribbble.com/ngbu931/collections/4640295
https://dribbble.com/asha926/collections/4637655,https://dribbble.com/ngbu931/collections/4640294
https://dribbble.com/asha926/collections/4637654,https://dribbble.com/ngbu931/collections/4640293
https://dribbble.com/asha926/collections/4637652,https://dribbble.com/ngbu931/collections/4640291
https://dribbble.com/asha926/collections/4637651,https://dribbble.com/ngbu931/collections/4640290
https://dribbble.com/asha926/collections/4637650,https://dribbble.com/ngbu931/collections/4640289
https://dribbble.com/asha926/collections/4637649,https://dribbble.com/ngbu931/collections/4640287
https://dribbble.com/asha926/collections/4637648,https://dribbble.com/ngbu931/collections/4640286
https://dribbble.com/asha926/collections/4637647,https://dribbble.com/ngbu931/collections/4640285
https://dribbble.com/asha926/collections/4637646,https://dribbble.com/ngbu931/collections/4640284
https://dribbble.com/asha926/collections/4637645,https://dribbble.com/ngbu931/collections/4640283
https://dribbble.com/asha926/collections/4637644,https://dribbble.com/ngbu931/collections/4640282
https://dribbble.com/asha926/collections/4637643,https://dribbble.com/ngbu931/collections/4640281
https://dribbble.com/asha926/collections/4637642,https://dribbble.com/ngbu931/collections/4640280
https://dribbble.com/asha926/collections/4637641,https://dribbble.com/ngbu931/collections/4640279
https://dribbble.com/asha926/collections/4637640,https://dribbble.com/ngbu931/collections/4640277
https://dribbble.com/shan394/collections/4637680,https://dribbble.com/nzho679/collections/4640346
https://dribbble.com/shan394/collections/4637679,https://dribbble.com/nzho679/collections/4640344
https://dribbble.com/shan394/collections/4637678,https://dribbble.com/nzho679/collections/4640341
https://dribbble.com/shan394/collections/4637676,https://dribbble.com/nzho679/collections/4640339
https://dribbble.com/shan394/collections/4637675,https://dribbble.com/nzho679/collections/4640337
https://dribbble.com/shan394/collections/4637674,https://dribbble.com/nzho679/collections/4640334
https://dribbble.com/shan394/collections/4637673,https://dribbble.com/nzho679/collections/4640332
https://dribbble.com/shan394/collections/4637672,https://dribbble.com/nzho679/collections/4640330
https://dribbble.com/shan394/collections/4637671,https://dribbble.com/nzho679/collections/4640327
https://dribbble.com/shan394/collections/4637670,https://dribbble.com/nzho679/collections/4640325
https://dribbble.com/shan394/collections/4637669,https://dribbble.com/nzho679/collections/4640323
https://dribbble.com/shan394/collections/4637668,https://dribbble.com/nzho679/collections/4640321
https://dribbble.com/shan394/collections/4637667,https://dribbble.com/nzho679/collections/4640318
https://dribbble.com/shan394/collections/4637666,https://dribbble.com/nzho679/collections/4640316
https://dribbble.com/shan394/collections/4637665,https://dribbble.com/nzho679/collections/4640314
https://dribbble.com/shan394/collections/4637664,https://dribbble.com/nzho679/collections/4640312
https://dribbble.com/shan394/collections/4637662,https://dribbble.com/nzho679/collections/4640310
https://dribbble.com/shan394/collections/4637661,https://dribbble.com/nzho679/collections/4640308
# 加载字体 from matplotlib import font_manager font = font_manager.FontProperties(fname="C:\Windows\Fonts\msyh.ttc") plt.plot(x,y,linewidth=10,color='red') plt.xlabel("x轴",fontproperties=font) plt.ylabel("y轴",fontproperties=font)
加载字体的时候,可以到C:\Windows\Fonts中找你喜欢的并且可以显示中文的字体。找到字体后,还需要找到字体的真实名称。方法是右键->属性->安全->对象名称:
- 设置标题:可以通过plt.title方法来实现。示例代码如下:
font = font_manager.FontProperties(fname="C:\Windows\Fonts\msyh.ttc") plt.title("sin函数",fontproperties=font)
- 设置x轴和y轴的刻度:之前我们画的图,x轴和y轴的刻度都是matplotlib自动生成的。如果想要在生成图的时候手动的指定,那么可以通过plt.xticks和plt.yticks来实现:
plt.xticks(range(0,20,2)) #在x轴上的刻度是0,2,4,6...20
以上会把那个刻度显示在x轴上。如果想要显示字符串类型,那么可以再构造一个数组,这个数组的长度必须和x轴刻度的长度保持一致。然后传给xticks的第二个参数。示例代码如下:
_x = range(0,20,2) _xticks = ["%d坐标"%i for i in _x] plt.xticks(_x,_xticks,fontproperties=font) #在x轴上的刻度是0坐标,2坐标...20坐标
同样y轴的刻度设置也是一样的。示例代码如下:
_y = np.arange(-1,1,0.25) _yticks = ["%.2f点"%i for i in _y] plt.yticks(_y,_yticks,fontproperties=font)
效果图如下:
复仇者联盟电影票房案例:
avenger = [17974.4,50918.4,30033.0,40329.1,52330.2,19833.3,11902.0,24322.6,47521.8,32262.0,22841.9,12938.7,4835.1,3118.1,2570.9,2267.9,1902.8,2548.9,5046.6,3600.8] plt.figure(figsize=(15,5)) plt.plot(avenger,marker="o") font.set_size(10) plt.xticks(range(20),["第%d天"%x for x in range(1,21)],fontproperties=font) plt.xlabel("天数",fontproperties=font) plt.ylabel("票房数(万)",fontproperties=font) plt.grid()
设置marker:
有时候,我们想要在一些关键点上重点标记出来。那么我们可以通过设置marker来实现。示例代码如下:
x = np.linspace(0,20) y = np.sin(x) plt.plot(x,y,marker="o")
我们设置了marker为o,这样就是会在(x,y)的坐标点上显示出来,并且显示的是圆点。其中o跟之前的线条样式的简写是一样的。另外,还可以通过markerfacecolor属性和markersize来指定标记点的颜色和大小。示例代码如下:
### 以下设置标记点的颜色为黑色,尺寸为10 plt.plot(x,y,marker="o",markerfacecolor='k',markersize=10)
设置注释文本:
有时候需要在图形中的某个点标记或者注释一下。那么我们可以使用plt.annotate(text,xy,xytext,arrowprops={})来实现,其中text是注释的文本,xy是需要注释的点的坐标,xytext是注释文本的坐标,arrowprops是箭头的样式属性。
示例代码如下:
ax = plt.subplot(111) x = np.arange(0.0, 5.0, 0.01) y = np.cos(2*np.pi*t) line, = plt.plot(x, y,linewidth=2) plt.annotate('local max', xy=(2, 1), xytext=(3, 1.5), arrowprops=dict(facecolor='black',shrink=0.05), ) plt.ylim(-2, 2) plt.show()
设置图形样式:
如果想要调整图片的大小和像素,可以通过plt.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)来实现。 其中num是图的编号,figsize的单位是英寸,dpi是每英寸的像素点,facecolor是图片背景颜色,edgecolor是边框颜色,frameon代表是否绘制画板。
示例代码如下:
plt.figure(figsize=(20,8),dpi=80) ### 其他的绘制图形的代码
我们也可以使用grid方法,来显示图片的网格:
plt.plot(x,y,color="r") plt.grid()
保存图片:
可以调用plt.savefig(path)来保存当前的图片。
示例代码如下:
plt.savefig("./abc.png")
今天的文章setlinestyle几个参数_ps关键帧设置怎么设置关键帧[通俗易懂]分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/85692.html