xinihe / jrxy_python_course

Python in Finance
72 stars 316 forks source link

Question 3 #7

Open leo8668 opened 4 years ago

leo8668 commented 4 years ago

下面这段代码中,log=False或者log=True对图像无任何影响,那样写出这个log干什么呢

gridsize = (3, 2) fig = plt.figure(figsize=(12, 8)) ax1 = plt.subplot2grid(gridsize, (0, 0), colspan=2, rowspan=2) ax2 = plt.subplot2grid(gridsize, (2, 0)) ax3 = plt.subplot2grid(gridsize, (2, 1))

ax1.set_title('Home value as a function of home age & area population',fontsize=14) sctr = ax1.scatter(x=age, y=pop, c=y) plt.colorbar(sctr, ax=ax1, format='$%d') ax1.set_yscale('log') ax2.hist(age, bins='auto') ax3.hist(pop, bins='auto', log=False)

这段代码中,line1.set_dashes([2, 2, 10,2])、 dashes=[6,3] 其中四个数值和两个数值具体的含义是什么呢? x = np.linspace(0, 10, 500) y = np.sin(x)

fig, ax = plt.subplots()

line1, = ax.plot(x, y, label='Using set_dashes()') line1.set_dashes([2, 2, 10,2])

Using plot(..., dashes=...) to set the dashing when creating a line

line2, = ax.plot(x, y - 0.2, dashes=[6,3], label='Using the dashes parameter')

ax.legend() plt.show()

xinihe commented 4 years ago

Log是改变坐标系的,有作用的。 set_dashes 和 dashes 是两种方案,可以达到同样的效果