绘制具有不同阴影的位置

时间:2015-07-29 09:52:05

标签: python matplotlib

我有一个包含3列的文件polar.dat:第一个是时间,第二个是半径r,第三个是极角theta。我想绘制位置(r,theta),使得点根据时间具有不同的颜色阴影。例如,使用红色,我希望第一个位置为浅红色,最终位置为深红色。

我正在使用python,pylab和matplotlib,所以我正在寻找这些库提供的命令。

1 个答案:

答案 0 :(得分:2)

您必须使用matplotlib colorbar来显示颜色。您必须在time的{​​{1}}选项中指定color

scatter

您可以查看可用的各种import matplotlib.pyplot as plt import numpy as np plt.rc('font',family='serif') time = np.random.random(100) radius = np.random.random(100) theta = np.random.random(100) fig = plt.figure() ax1 = fig.add_subplot(111) im = ax1.scatter(radius,theta,c=time,s=40,cmap=plt.cm.Reds) ax1.set_xlabel('radius') ax1.set_ylabel('theta') plt.colorbar(im,ax=ax1) fig.show() 选项at this website. 对于您的具体案例,我们正在使用colormap enter image description here